ivr-tester-transcriber-google-speech-to-text
Version:
Google Speech-to-Text integration for IVR Tester
27 lines (26 loc) • 1.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.googleSpeechToText = void 0;
const speech_1 = require("@google-cloud/speech");
const GoogleSpeechToText_1 = require("./GoogleSpeechToText");
/**
* Factory for creating a Google Speech-to-Text transcriber plugin that is preconfigured for
* phone-calls - specifically 8-bit PCM mono uLaw with a sampling rate of 8Khz.
*/
const googleSpeechToText = ({ languageCode = "en-US", speechPhrases = [], useEnhanced = false, } = {}, speechClient = new speech_1.SpeechClient()) => ({
create: () => new GoogleSpeechToText_1.GoogleSpeechToText(languageCode, speechPhrases, useEnhanced, speechClient),
checkCanRun: async () => {
try {
await speechClient.auth.getCredentials();
}
catch (error) {
return {
canRun: false,
reason: `Cannot find Google Speech-to-Text credentials:\n${error.message}`,
};
}
return { canRun: true };
},
});
exports.googleSpeechToText = googleSpeechToText;
exports.default = exports.googleSpeechToText;