add support for multiple languages when using Azure STT

This commit is contained in:
Dave Horton
2022-04-26 15:07:55 -04:00
parent af33089a8a
commit 72aaf80335
2 changed files with 8 additions and 0 deletions

View File

@@ -208,6 +208,7 @@ class TaskTranscribe extends Task {
if (this.hints && this.hints.length > 1) {
opts.AZURE_SPEECH_HINTS = this.hints.map((h) => h.trim()).join(',');
}
if (this.altLanguages.length > 1) opts.AZURE_SPEECH_ALTERNATIVE_LANGUAGE_CODES = this.altLanguages.join(',');
if (this.requestSnr) opts.AZURE_REQUEST_SNR = 1;
if (this.profanityOption !== 'raw') opts.AZURE_PROFANITY_OPTION = this.profanityOption;
if (this.initialSpeechTimeoutMs > 0) opts.AZURE_INITIAL_SPEECH_TIMEOUT_MS = this.initialSpeechTimeoutMs;
@@ -234,6 +235,7 @@ class TaskTranscribe extends Task {
if ('aws' === this.vendor && Array.isArray(evt) && evt.length > 0) evt = evt[0];
if ('microsoft' === this.vendor) {
const nbest = evt.NBest;
const language_code = evt.PrimaryLanguage?.Language || this.language;
const alternatives = nbest ? nbest.map((n) => {
return {
confidence: n.Confidence,
@@ -248,6 +250,7 @@ class TaskTranscribe extends Task {
const newEvent = {
is_final: evt.RecognitionStatus === 'Success',
language_code,
alternatives
};
evt = newEvent;