support assembly ai (#248)

* support assembly ai

* wip

* wip
This commit is contained in:
Hoan Luu Huu
2023-11-01 08:02:32 -04:00
committed by GitHub
parent 30ba84d57b
commit f15c339a2a
5 changed files with 90 additions and 2 deletions
+29 -1
View File
@@ -5,6 +5,7 @@ const sdk = require('microsoft-cognitiveservices-speech-sdk');
const { SpeechClient } = require('@soniox/soniox-node');
const bent = require('bent');
const fs = require('fs');
const { AssemblyAI } = require('assemblyai');
const testSonioxStt = async(logger, credentials) => {
@@ -260,6 +261,32 @@ const testWellSaidStt = async(logger, credentials) => {
return true;
};
const testAssemblyStt = async(logger, credentials) => {
const {api_key} = credentials;
const assemblyai = new AssemblyAI({
apiKey: api_key
});
const audioUrl = `${__dirname}/../../data/test_audio.wav`;
return new Promise((resolve, reject) => {
assemblyai.transcripts
.create({ audio_url: audioUrl })
.then((transcript) => {
logger.debug({transcript}, 'got transcription from AssemblyAi');
if (transcript.status === 'error') {
return reject({message: transcript.error});
}
return resolve(transcript.text);
})
.catch((err) => {
logger.info({err}, 'failed to get assemblyAI transcription');
reject(err);
});
});
};
module.exports = {
testGoogleTts,
testGoogleStt,
@@ -275,5 +302,6 @@ module.exports = {
testIbmTts,
testIbmStt,
testSonioxStt,
testElevenlabs
testElevenlabs,
testAssemblyStt
};