Add tests
This commit is contained in:
@ -61,7 +61,7 @@ export const createSpeechMarks = async (
|
||||
}
|
||||
try {
|
||||
const data = await client.synthesizeSpeech(params).promise()
|
||||
return data.AudioStream as string
|
||||
return (data.AudioStream as Buffer).toString()
|
||||
} catch (error) {
|
||||
logger.error('Unable to create speech marks', { error })
|
||||
throw error
|
||||
@ -90,7 +90,7 @@ export const createAudioWithSpeechMarks = async (
|
||||
speechMarks,
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('Unable to create audio with speech marks', { error })
|
||||
logger.error('Unable to create audio with speech marks', error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
23
packages/api/test/utils/textToSpeech.test.ts
Normal file
23
packages/api/test/utils/textToSpeech.test.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import 'mocha'
|
||||
import {
|
||||
createAudioWithSpeechMarks,
|
||||
TextToSpeechInput,
|
||||
} from '../../src/utils/textToSpeech'
|
||||
import { expect } from 'chai'
|
||||
import { generateFakeUuid } from '../util'
|
||||
|
||||
describe('textToSpeech', () => {
|
||||
describe('createAudioWithSpeechMarks', () => {
|
||||
it('should create an audio file with speech marks', async () => {
|
||||
const input: TextToSpeechInput = {
|
||||
id: generateFakeUuid(),
|
||||
title: 'Hello World',
|
||||
text: 'Hello World',
|
||||
engine: 'standard',
|
||||
}
|
||||
const output = await createAudioWithSpeechMarks(input)
|
||||
expect(output.audioUrl).to.be.a('string')
|
||||
expect(output.speechMarks).to.be.a('string')
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user