mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 00:09:24 +08:00
Ship the reading, listening, question-bank, parsing, and provider updates summarized in assets/releases/ver1-6-13.md. Make speech timeouts configurable, report actionable synthesis failures, and keep chat attachments discoverable in their selected workspace while preserving earlier uploads and URLs. Keep reply playback cancellation and single-audio ownership intact. Sync README prose and all eleven translations, update the stable install note, and archive release notes older than one week. Repair stale reading test fixtures and spawned test imports, and clear the Partner type error. Validation: 9252 Python tests and 8 subtests passed (28 skipped); 518 web unit tests, 1253 Node tests, and 62 browser audits passed. Pre-commit, ruff, typecheck, contracts, architecture, i18n, production build, route budgets, and the docs build passed.
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import type { CatalogModel, VoiceOptions, VoiceModelOption } from './model-catalog-types'
|
|
|
|
export const DEFAULT_SPEECH_REQUEST_TIMEOUT = 60
|
|
export const MIN_SPEECH_REQUEST_TIMEOUT = 5
|
|
export const MAX_SPEECH_REQUEST_TIMEOUT = 600
|
|
export const SPEECH_TIMEOUT_MESSAGE =
|
|
'Speech synthesis timed out. Increase Request timeout (seconds) in the speech model settings or try shorter text.'
|
|
export const SPEECH_PLAYBACK_FAILURE_MESSAGE =
|
|
'Speech playback failed. Check the speech model settings and provider connection.'
|
|
|
|
export function speechRequestTimeout(model: CatalogModel | undefined): number {
|
|
const seconds = Number(model?.request_timeout)
|
|
return Number.isInteger(seconds) && seconds >= MIN_SPEECH_REQUEST_TIMEOUT && seconds <= MAX_SPEECH_REQUEST_TIMEOUT
|
|
? seconds
|
|
: DEFAULT_SPEECH_REQUEST_TIMEOUT
|
|
}
|
|
|
|
export function voiceModelOptions(
|
|
options: VoiceOptions | undefined,
|
|
model: string
|
|
): VoiceModelOption | undefined {
|
|
return (
|
|
options?.models
|
|
.slice()
|
|
.sort((a, b) => b.id.length - a.id.length)
|
|
.find(item => item.id === model || model.startsWith(`${item.id}-`)) ?? options?.fallback
|
|
)
|
|
}
|