@@ -31,7 +31,7 @@ import { TranslatePageQueryParams } from '../@types/navigate';
3131import { MODELS } from '../hooks/useModel' ;
3232import { getPrompter } from '../prompts' ;
3333import queryString from 'query-string' ;
34- import useSpeach from '../hooks/useSpeach ' ;
34+ import useSpeech from '../hooks/useSpeech ' ;
3535import { useTranslation } from 'react-i18next' ;
3636
3737const languages = [ 'en' , 'ja' , 'zh' , 'ko' , 'fr' , 'es' , 'de' , 'th' , 'vi' ] ;
@@ -125,7 +125,7 @@ const TranslatePage: React.FC = () => {
125125 const stopReason = getStopReason ( ) ;
126126 const [ auto , setAuto ] = useLocalStorageBoolean ( 'Auto_Translate' , true ) ;
127127 const [ audio , setAudioInput ] = useState ( false ) ; // Audio input flag
128- const { synthesizeSpeach , loading : speachIsLoading } = useSpeach ( language ) ;
128+ const { synthesizeSpeech , loading : speechIsLoading } = useSpeech ( language ) ;
129129
130130 useEffect ( ( ) => {
131131 updateSystemContextByModel ( ) ;
@@ -257,41 +257,41 @@ const TranslatePage: React.FC = () => {
257257 } , [ ] ) ;
258258
259259 const audioRef = useRef < HTMLAudioElement | null > ( null ) ;
260- const [ isSpeachPlaying , setIsSpeachPlaying ] = useState ( false ) ;
260+ const [ isSpeechPlaying , setIsSpeechPlaying ] = useState ( false ) ;
261261
262- const handleSpeachEnded = useCallback ( ( ) => {
263- setIsSpeachPlaying ( false ) ;
264- } , [ setIsSpeachPlaying ] ) ;
262+ const handleSpeechEnded = useCallback ( ( ) => {
263+ setIsSpeechPlaying ( false ) ;
264+ } , [ setIsSpeechPlaying ] ) ;
265265
266- const startOrStopSpeach = useCallback ( async ( ) => {
267- if ( speachIsLoading ) return ;
266+ const startOrStopSpeech = useCallback ( async ( ) => {
267+ if ( speechIsLoading ) return ;
268268
269269 // If it is playing, stop it
270- if ( isSpeachPlaying && audioRef . current ) {
271- setIsSpeachPlaying ( false ) ;
270+ if ( isSpeechPlaying && audioRef . current ) {
271+ setIsSpeechPlaying ( false ) ;
272272
273273 audioRef . current . pause ( ) ;
274274 audioRef . current . currentTime = 0 ;
275275 audioRef . current = null ;
276276 return ;
277277 }
278278
279- setIsSpeachPlaying ( true ) ;
279+ setIsSpeechPlaying ( true ) ;
280280
281- const speachUrl = await synthesizeSpeach ( translatedSentence ) ;
282- const audio = new Audio ( speachUrl ! ) ;
281+ const speechUrl = await synthesizeSpeech ( translatedSentence ) ;
282+ const audio = new Audio ( speechUrl ! ) ;
283283
284284 audioRef . current = audio ;
285- audio . addEventListener ( 'ended' , handleSpeachEnded ) ;
285+ audio . addEventListener ( 'ended' , handleSpeechEnded ) ;
286286 audio . play ( ) ;
287287 } , [
288288 translatedSentence ,
289- synthesizeSpeach ,
289+ synthesizeSpeech ,
290290 audioRef ,
291- setIsSpeachPlaying ,
292- isSpeachPlaying ,
293- handleSpeachEnded ,
294- speachIsLoading ,
291+ setIsSpeechPlaying ,
292+ isSpeechPlaying ,
293+ handleSpeechEnded ,
294+ speechIsLoading ,
295295 ] ) ;
296296
297297 return (
@@ -381,8 +381,8 @@ const TranslatePage: React.FC = () => {
381381 </ div >
382382 ) }
383383 < div className = "flex w-full justify-end" >
384- < ButtonIcon onClick = { startOrStopSpeach } >
385- { isSpeachPlaying ? (
384+ < ButtonIcon onClick = { startOrStopSpeech } >
385+ { isSpeechPlaying ? (
386386 < PiSpeakerSimpleHighFill />
387387 ) : (
388388 < PiSpeakerSimpleHigh />
0 commit comments