mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
The auto-play hook returned early whenever the last assistant message was still streaming, before it could record that a reply had started, so the first reply in a fresh session was never spoken. Remove that input and rely on the message's own completion state. Auto-play now speaks every completed assistant step and queues steps that arrive during playback, resuming after a short pause, rather than interrupting the audio in progress. Manual playback and stop still interrupt and clear the queue.
33 lines
860 B
TypeScript
33 lines
860 B
TypeScript
import { createContext } from 'react'
|
|
|
|
export type TTSState = 'idle' | 'loading' | 'playing' | 'error'
|
|
|
|
export interface TTSConfig {
|
|
enabled: boolean
|
|
provider: 'external' | 'builtin'
|
|
endpoint: string
|
|
apiKey: string
|
|
voice: string
|
|
model: string
|
|
speed: number
|
|
}
|
|
|
|
export interface TTSContextValue {
|
|
speak: (text: string) => Promise<boolean>
|
|
speakWithConfig: (text: string, config: TTSConfig) => Promise<boolean>
|
|
speakMessage: (messageId: string, text: string) => Promise<boolean>
|
|
queueMessage: (messageId: string, text: string) => void
|
|
stop: () => void
|
|
state: TTSState
|
|
error: string | null
|
|
currentText: string | null
|
|
originalText: string | null
|
|
activeMessageId: string | null
|
|
isEnabled: boolean
|
|
isPlaying: boolean
|
|
isLoading: boolean
|
|
isIdle: boolean
|
|
}
|
|
|
|
export const TTSContext = createContext<TTSContextValue | null>(null)
|