mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add tests
This commit is contained in:
parent
bca0f5ed59
commit
dd332f5ee6
2 changed files with 25 additions and 2 deletions
|
|
@ -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')
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
Reference in a new issue