Improve error logging in tts cloud functions
This commit is contained in:
@ -279,7 +279,12 @@ const textToUtterance = ({
|
||||
try {
|
||||
textWithWordOffset = htmlToText(text, { wordwrap: false })
|
||||
} catch (err) {
|
||||
console.error('Unable to convert HTML to text', { text, err })
|
||||
console.error(
|
||||
'Unable to convert HTML to text, html:',
|
||||
text,
|
||||
', error:',
|
||||
err
|
||||
)
|
||||
textWithWordOffset =
|
||||
parseHTML(text).document.documentElement.textContent ?? text
|
||||
console.info('Converted HTML to text:', textWithWordOffset)
|
||||
|
||||
@ -84,7 +84,7 @@ export const textToSpeechHandler = Sentry.GCPFunction.wrapHttpFunction(
|
||||
try {
|
||||
jwt.verify(token, process.env.JWT_SECRET)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
console.error('Authentication error:', e)
|
||||
return res.status(200).send('UNAUTHENTICATED')
|
||||
}
|
||||
// validate input
|
||||
@ -92,7 +92,7 @@ export const textToSpeechHandler = Sentry.GCPFunction.wrapHttpFunction(
|
||||
const id = input.id
|
||||
const bucket = input.bucket
|
||||
if (!id || !bucket) {
|
||||
return res.status(200).send('Invalid data')
|
||||
return res.status(200).send('INVALID_INPUT')
|
||||
}
|
||||
try {
|
||||
// audio file to be saved in GCS
|
||||
@ -133,7 +133,7 @@ export const textToSpeechHandler = Sentry.GCPFunction.wrapHttpFunction(
|
||||
console.info('Text to speech cloud function completed')
|
||||
res.send('OK')
|
||||
} catch (e) {
|
||||
console.error('Text to speech cloud function error', e)
|
||||
console.error('Text to speech cloud function error:', e)
|
||||
await updateSpeech(id, token, 'FAILED')
|
||||
return res.status(500).send({ errorCodes: 'SYNTHESIZER_ERROR' })
|
||||
}
|
||||
@ -149,13 +149,13 @@ export const textToSpeechStreamingHandler = Sentry.GCPFunction.wrapHttpFunction(
|
||||
}
|
||||
const token = (req.query.token || req.headers.authorization) as string
|
||||
if (!token) {
|
||||
return res.status(401).send({ errorCode: 'UNAUTHORIZED' })
|
||||
return res.status(401).send({ errorCode: 'INVALID_TOKEN' })
|
||||
}
|
||||
try {
|
||||
jwt.verify(token, process.env.JWT_SECRET)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
return res.status(401).send({ errorCode: 'UNAUTHORIZED' })
|
||||
console.error('Authentication error:', e)
|
||||
return res.status(401).send({ errorCode: 'UNAUTHENTICATED' })
|
||||
}
|
||||
|
||||
try {
|
||||
@ -174,7 +174,7 @@ export const textToSpeechStreamingHandler = Sentry.GCPFunction.wrapHttpFunction(
|
||||
speechMarks,
|
||||
})
|
||||
} catch (e) {
|
||||
console.error('Text to speech streaming error', e)
|
||||
console.error('Text to speech streaming error:', e)
|
||||
return res.status(500).send({ errorCodes: 'SYNTHESIZER_ERROR' })
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ export const synthesizeTextToSpeech = async (
|
||||
if (cancellationDetails.reason === CancellationReason.Error) {
|
||||
str += ': ' + e.result.errorDetails
|
||||
}
|
||||
console.error(str)
|
||||
console.error('synthesis error:', str)
|
||||
}
|
||||
|
||||
// The unit of e.audioOffset is tick (1 tick = 100 nanoseconds), divide by 10,000 to convert to milliseconds.
|
||||
@ -157,7 +157,7 @@ export const synthesizeTextToSpeech = async (
|
||||
speechMarks,
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('synthesis error', error)
|
||||
console.error('synthesis error:', error)
|
||||
throw error
|
||||
} finally {
|
||||
console.log('closing synthesizer')
|
||||
|
||||
Reference in New Issue
Block a user