Skip to content

Commit

Permalink
Fix TTS API call (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles committed Dec 1, 2023
1 parent 63404ee commit 96e158f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion core/api/tts/tts.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ module.exports = function TTSController(redisClient) {
const { data, headers } = await axios({
url: process.env.TEXT_TO_SPEECH_URL,
method: 'POST',
body: req.body,
data: {
text: req.query.text,
},
headers: {
authorization: `Bearer ${process.env.TEXT_TO_SPEECH_API_KEY}`,
},
Expand Down
9 changes: 7 additions & 2 deletions test/core/api/tts/tts.controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ describe('TTS API', () => {
process.env.GLADYS_PLUS_BACKEND_URL = 'http://test-api.com';
});
it('should get token + get mp3', async () => {
nock(process.env.TEXT_TO_SPEECH_URL, { encodedQueryParams: true })
.post('/', (body) => true)
nock(process.env.TEXT_TO_SPEECH_URL, {
encodedQueryParams: true,
reqheaders: {
authorization: 'Bearer my-token',
},
})
.post('/', { text: 'bonjour' })
.reply(200, voiceFile, {
'content-type': 'audio/mpeg',
'content-length': 36362,
Expand Down

0 comments on commit 96e158f

Please sign in to comment.