Add pageId to speech-file

This commit is contained in:
Hongbo Wu 2022-09-07 22:51:44 +08:00
parent 3cf3d40482
commit 9a62a3c31e
3 changed files with 2 additions and 6 deletions

View file

@ -102,7 +102,7 @@ export function articleRouter() {
},
})
if (outputFormat === 'speech-file') {
if (outputFormat === 'speech') {
const page = await getPageById(articleId)
if (!page) {
return res.status(404).send('Page not found')
@ -112,7 +112,7 @@ export function articleRouter() {
secondaryVoice: secondaryVoice,
language: page.language,
})
return res.send(speechFile)
return res.send({ ...speechFile, pageId: articleId })
}
const existingSpeech = await getRepository(Speech).findOne({

View file

@ -21,7 +21,6 @@ declare module '@omnivore/text-to-speech-handler' {
export interface SpeechFile {
wordCount: number
averageWPM: number
language: string
defaultVoice: string
utterances: Utterance[]

View file

@ -16,7 +16,6 @@ export interface Utterance {
export interface SpeechFile {
wordCount: number
averageWPM: number
language: string
defaultVoice: string
utterances: Utterance[]
@ -37,7 +36,6 @@ export type SSMLOptions = {
language?: string
}
const WORDS_PER_MINUTE = 200
const DEFAULT_LANGUAGE = 'en-US'
const DEFAULT_VOICE = 'en-US-JennyNeural'
const DEFAULT_RATE = 1.25
@ -307,7 +305,6 @@ export const htmlToSpeechFile = (
return {
wordCount: wordOffset,
averageWPM: WORDS_PER_MINUTE,
language: options.language || DEFAULT_LANGUAGE,
defaultVoice: options.primaryVoice || DEFAULT_VOICE,
utterances,