Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Adding Alternative Language Support to AWS Transcribe #132

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions modules/mod_aws_transcribe/aws_transcribe_glue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class GStreamer {

// not worth resampling to 16k if we get 8k ulaw or alaw in..
m_request.SetMediaSampleRateHertz(samples_per_second > 8000 ? 16000 : 8000);
m_request.SetLanguageCode(LanguageCodeMapper::GetLanguageCodeForName(lang));
// setting this lower instead because it can't be used if SetIdentifyLanguage is also used. See below.
//m_request.SetLanguageCode(LanguageCodeMapper::GetLanguageCodeForName(lang));
m_request.SetMediaEncoding(MediaEncoding::pcm);
m_request.SetEventStreamHandler(m_handler);
if (channels > 1) m_request.SetNumberOfChannels(channels);
Expand All @@ -110,6 +111,19 @@ class GStreamer {
if (var = switch_channel_get_variable(channel, "AWS_VOCABULARY_FILTER_METHOD")) {
m_request.SetVocabularyFilterMethod(VocabularyFilterMethodMapper::GetVocabularyFilterMethodForName(var));
}
// LP: I saw this in some other commit of Dave's but it wasn't in master. NB: this was added in AWS SDK 1.9
if (var = switch_channel_get_variable(channel, "AWS_ENABLE_PARTIAL_RESULTS_STABILITY")) {
m_request.SetEnablePartialResultsStabilization(true);
m_request.SetPartialResultsStability(PartialResultsStabilityMapper::GetPartialResultsStabilityForName(var));
}
if (var = switch_channel_get_variable(channel, "AWS_LANGUAGE_ALTERNATIVES")) {
m_request.SetIdentifyLanguage(true);
m_request.SetLanguageOptions(var);
m_request.SetPreferredLanguage(LanguageCodeMapper::GetLanguageCodeForName(lang));
}
else {
m_request.SetLanguageCode(LanguageCodeMapper::GetLanguageCodeForName(lang));
}
switch_core_session_rwunlock(session);
}

Expand Down Expand Up @@ -583,4 +597,4 @@ extern "C" {
}
return SWITCH_TRUE;
}
}
}