Another nlp optimization
This commit is contained in:
parent
f16116cab4
commit
2a9510aa55
1 changed files with 2 additions and 14 deletions
|
|
@ -456,20 +456,8 @@ export function TTSProvider({ children }: { children: React.ReactNode }) {
|
||||||
// Only set processing state if not preloading
|
// Only set processing state if not preloading
|
||||||
if (!preload) setIsProcessing(true);
|
if (!preload) setIsProcessing(true);
|
||||||
|
|
||||||
// Preprocess the sentence using the NLP API
|
// No need to preprocess again since setText already did it
|
||||||
const response = await fetch('/api/nlp', {
|
const audioBuffer = await getAudio(sentence);
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
body: JSON.stringify({ text: sentence }),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error('Failed to process sentence');
|
|
||||||
}
|
|
||||||
|
|
||||||
const { sentences: [cleanedSentence] } = await response.json();
|
|
||||||
const audioBuffer = await getAudio(cleanedSentence);
|
|
||||||
|
|
||||||
return audioBufferToURL(audioBuffer!);
|
return audioBufferToURL(audioBuffer!);
|
||||||
}, [isProcessing, audioContext, getAudio]);
|
}, [isProcessing, audioContext, getAudio]);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue