mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Merge dev: STT feature, git date fixes, and session improvements (#82)
* fix session last active * Feature/sst (#81) * Use CSS field-sizing for textarea auto-height and abort STT recording on clear * Fix invalid date display in git commits * Use Unix timestamps for git log dates
This commit is contained in:
1 parent
21010956f7
commit
cb1714a4e0
17 files changed
+2475
-76
No files matched your search
@@ -0,0 +1,65 @@
|
||||
import axios from 'axios'
|
||||
import { API_BASE_URL } from '@/config'
|
||||
|
||||
export interface STTModelsResponse {
|
||||
models: string[]
|
||||
cached: boolean
|
||||
}
|
||||
|
||||
export interface STTStatusResponse {
|
||||
enabled: boolean
|
||||
configured: boolean
|
||||
provider: 'external' | 'builtin'
|
||||
model: string
|
||||
}
|
||||
|
||||
export interface STTTranscribeResponse {
|
||||
text: string
|
||||
}
|
||||
|
||||
export interface STTErrorResponse {
|
||||
error: string
|
||||
details?: string
|
||||
}
|
||||
|
||||
export const sttApi = {
|
||||
getModels: async (userId = 'default', forceRefresh = false): Promise<STTModelsResponse> => {
|
||||
const { data } = await axios.get(`${API_BASE_URL}/api/stt/models`, {
|
||||
params: { userId, ...(forceRefresh && { refresh: 'true' }) },
|
||||
})
|
||||
return data
|
||||
},
|
||||
|
||||
getStatus: async (userId = 'default'): Promise<STTStatusResponse> => {
|
||||
const { data } = await axios.get(`${API_BASE_URL}/api/stt/status`, {
|
||||
params: { userId },
|
||||
})
|
||||
return data
|
||||
},
|
||||
|
||||
transcribe: async (
|
||||
audioBlob: Blob,
|
||||
userId = 'default',
|
||||
signal?: AbortSignal
|
||||
): Promise<STTTranscribeResponse> => {
|
||||
const formData = new FormData()
|
||||
|
||||
const extension = audioBlob.type.includes('webm') ? 'webm' :
|
||||
audioBlob.type.includes('ogg') ? 'ogg' :
|
||||
audioBlob.type.includes('mp4') ? 'm4a' : 'webm'
|
||||
formData.append('audio', audioBlob, `recording.${extension}`)
|
||||
|
||||
const { data } = await axios.post<STTTranscribeResponse>(
|
||||
`${API_BASE_URL}/api/stt/transcribe`,
|
||||
formData,
|
||||
{
|
||||
params: { userId },
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
signal,
|
||||
}
|
||||
)
|
||||
return data
|
||||
},
|
||||
}
|
||||
Reference in new issue
Block a user