diff --git a/packages/text-to-speech/src/htmlToSsml.ts b/packages/text-to-speech/src/htmlToSsml.ts
index b90142f63..ed125114d 100644
--- a/packages/text-to-speech/src/htmlToSsml.ts
+++ b/packages/text-to-speech/src/htmlToSsml.ts
@@ -91,7 +91,7 @@ function emitTextNode(
if (ssmlElement) {
emit(textItems, `<${ssmlElement}>`)
}
- emit(textItems, `${cleanedText}`)
+ emit(textItems, `${cleanedText.replace(/\s+/g, ' ')}`)
if (ssmlElement) {
emit(textItems, `${ssmlElement}>`)
}
@@ -123,7 +123,7 @@ function emitElement(
) {
const cleanedText = cleanTextNode(child)
if (idx && cleanedText.length > 1) {
- // Make sure its more than just a space
+ // Make sure it's more than just a space
emit(textItems, ``)
}
emitTextNode(textItems, cleanedText, child)
@@ -158,9 +158,7 @@ const startSsml = (element: Element, options: SSMLOptions): string => {
element.nodeName === 'BLOCKQUOTE'
? options.secondaryVoice
: options.primaryVoice
- return `
-
- `
+ return ``
}
const endSsml = (): string => {
diff --git a/packages/text-to-speech/src/index.ts b/packages/text-to-speech/src/index.ts
index d5329b11e..55a9eabc6 100644
--- a/packages/text-to-speech/src/index.ts
+++ b/packages/text-to-speech/src/index.ts
@@ -10,7 +10,7 @@ import * as dotenv from 'dotenv' // see https://github.com/motdotla/dotenv#how-d
import { synthesizeTextToSpeech, TextToSpeechInput } from './textToSpeech'
import { File, Storage } from '@google-cloud/storage'
import { PassThrough } from 'stream'
-import { SSMLItem } from './htmlToSsml'
+import { htmlToSsml, SSMLItem } from './htmlToSsml'
dotenv.config()
Sentry.GCPFunction.init({
@@ -164,3 +164,9 @@ export const textToSpeechStreamingHandler = Sentry.GCPFunction.wrapHttpFunction(
}
}
)
+
+module.exports = {
+ htmlToSsml,
+ textToSpeechStreamingHandler,
+ textToSpeechHandler,
+}
diff --git a/packages/text-to-speech/src/textToSpeech.ts b/packages/text-to-speech/src/textToSpeech.ts
index 2217fe1a1..ed7799e2b 100644
--- a/packages/text-to-speech/src/textToSpeech.ts
+++ b/packages/text-to-speech/src/textToSpeech.ts
@@ -46,7 +46,6 @@ export const synthesizeTextToSpeech = async (
process.env.AZURE_SPEECH_KEY,
process.env.AZURE_SPEECH_REGION
)
- const textType = input.textType || 'html'
speechConfig.speechSynthesisOutputFormat =
SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3