mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Create buffer for the audio data
This commit is contained in:
parent
d4dcec75d5
commit
baaa38547a
2 changed files with 11 additions and 5 deletions
|
|
@ -170,9 +170,12 @@ export const textToSpeechStreamingHandler = Sentry.GCPFunction.wrapHttpFunction(
|
|||
...utteranceInput,
|
||||
textType: 'utterance',
|
||||
}
|
||||
const { audioStream, speechMarks } = await synthesizeTextToSpeech(input)
|
||||
const { audioData, speechMarks } = await synthesizeTextToSpeech(input)
|
||||
if (!audioData) {
|
||||
return res.status(500).send({ errorCode: 'SYNTHESIZER_ERROR' })
|
||||
}
|
||||
res.send({
|
||||
audioData: audioStream.read().toString('hex'),
|
||||
audioData: audioData.toString('hex'),
|
||||
speechMarks,
|
||||
})
|
||||
} catch (e) {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export interface TextToSpeechInput {
|
|||
}
|
||||
|
||||
export interface TextToSpeechOutput {
|
||||
audioStream: NodeJS.ReadWriteStream
|
||||
audioData?: Buffer
|
||||
speechMarks: SpeechMark[]
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +146,11 @@ export const synthesizeTextToSpeech = async (
|
|||
} else {
|
||||
// assemble ssml
|
||||
const ssml = `${startSsml(null, ssmlOptions)}${input.text}${endSsml()}`
|
||||
await speakSsmlAsyncPromise(ssml)
|
||||
const result = await speakSsmlAsyncPromise(ssml)
|
||||
return {
|
||||
audioData: Buffer.from(result.audioData),
|
||||
speechMarks,
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('synthesis error', error)
|
||||
|
|
@ -159,7 +163,6 @@ export const synthesizeTextToSpeech = async (
|
|||
}
|
||||
|
||||
return {
|
||||
audioStream,
|
||||
speechMarks,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue