Просмотр исходного кода

feat: speed up Azure TTS playback to +15%

Wrap the SSML body in <prosody rate='+15%'> so AI voice plays
slightly faster than the default natural rate. Centralized as a
RATE constant — change -10% / +25% etc. for tuning.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jimmylee 2 месяцев назад
Родитель
Сommit
6904e7fbde
1 измененных файлов с 5 добавлено и 1 удалено
  1. 5 1
      src/views/Editor/EnglishSpeaking/services/speechService.ts

+ 5 - 1
src/views/Editor/EnglishSpeaking/services/speechService.ts

@@ -2,6 +2,8 @@ const KEY = import.meta.env.VITE_AZURE_SPEECH_KEY as string | undefined
 const REGION = import.meta.env.VITE_AZURE_SPEECH_REGION as string | undefined
 const VOICE = 'en-US-AriaNeural'
 const FORMAT = 'audio-24khz-48kbitrate-mono-mp3'
+// 默认偏自然偏快;调慢改 -10%、调更快改 +25% 之类。
+const RATE = '+15%'
 
 /**
  * Synthesize English text via Azure Speech REST.
@@ -18,7 +20,9 @@ export async function synthesize(text: string, signal?: AbortSignal): Promise<Bl
 
   const ssml =
     `<speak version='1.0' xml:lang='en-US'>` +
-    `<voice name='${VOICE}'>${escapeXml(text)}</voice>` +
+    `<voice name='${VOICE}'>` +
+    `<prosody rate='${RATE}'>${escapeXml(text)}</prosody>` +
+    `</voice>` +
     `</speak>`
 
   const res = await fetch(