From fd805ccca90c3283fd933f9e994aaafa9607aefb Mon Sep 17 00:00:00 2001 From: nemerald-voip <58834187+nemerald-voip@users.noreply.github.com> Date: Tue, 30 Mar 2021 11:02:35 -0700 Subject: [PATCH 1/4] Fix voicemail transcription using Google Transcriptions using Google were broken after last commit. transcribe_alternate_language was not defined anywhere it Google would return 400 error. Added variable to fix the issue --- .../app/voicemail/resources/functions/record_message.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua b/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua index 93a61d9c68..8d8cd51031 100644 --- a/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua +++ b/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua @@ -281,8 +281,9 @@ if (transcribe_provider == "google") then local api_key = settings:get('voicemail', 'google_key', 'text') or ''; local transcription_server = settings:get('voicemail', 'google_url', 'text') or ''; + transcribe_alternate_language = settings:get('voicemail', 'transcribe_alternate_language', 'text') or 'es-US'; if (api_key ~= '') then - transcribe_cmd = [[sox ]]..file_path..[[ ]]..file_path..[[.flac trim 0 00:59 && echo "{ 'config': { 'languageCode': 'en-US', 'enableWordTimeOffsets': false , 'enableAutomaticPunctuation': true , 'alternativeLanguageCodes': 'es' }, 'audio': { 'content': '`base64 -w 0 ]]..file_path..[[.flac`' } }" | curl -X POST -H "Content-Type: application/json" -d @- "]]..transcription_server..[[:recognize?key=]]..api_key..[[" && rm -f ]]..file_path..[[.flac]] + transcribe_cmd = [[sox ]]..file_path..[[ ]]..file_path..[[.flac trim 0 00:59 && echo "{ 'config': { 'languageCode': ']]..transcribe_language..[[', 'enableWordTimeOffsets': false , 'enableAutomaticPunctuation': true , 'alternativeLanguageCodes': ']]..transcribe_alternate_language..[[' }, 'audio': { 'content': '`base64 -w 0 ]]..file_path..[[.flac`' } }" | curl -X POST -H "Content-Type: application/json" -d @- "]]..transcription_server..[[:recognize?key=]]..api_key..[[" && rm -f ]]..file_path..[[.flac]] end local handle = io.popen(transcribe_cmd); From c1057293b515f0314365f4923634539e91433480 Mon Sep 17 00:00:00 2001 From: nemerald-voip <58834187+nemerald-voip@users.noreply.github.com> Date: Tue, 30 Mar 2021 11:02:35 -0700 Subject: [PATCH 2/4] Fix voicemail transcription using Google Transcriptions using Google were broken after last commit. transcribe_alternate_language was not defined anywhere it Google would return 400 error. Added variable to fix the issue --- .../scripts/app/voicemail/resources/functions/record_message.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua b/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua index 09c5a92cb6..8d8cd51031 100644 --- a/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua +++ b/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua @@ -281,6 +281,7 @@ if (transcribe_provider == "google") then local api_key = settings:get('voicemail', 'google_key', 'text') or ''; local transcription_server = settings:get('voicemail', 'google_url', 'text') or ''; + transcribe_alternate_language = settings:get('voicemail', 'transcribe_alternate_language', 'text') or 'es-US'; if (api_key ~= '') then transcribe_cmd = [[sox ]]..file_path..[[ ]]..file_path..[[.flac trim 0 00:59 && echo "{ 'config': { 'languageCode': ']]..transcribe_language..[[', 'enableWordTimeOffsets': false , 'enableAutomaticPunctuation': true , 'alternativeLanguageCodes': ']]..transcribe_alternate_language..[[' }, 'audio': { 'content': '`base64 -w 0 ]]..file_path..[[.flac`' } }" | curl -X POST -H "Content-Type: application/json" -d @- "]]..transcription_server..[[:recognize?key=]]..api_key..[[" && rm -f ]]..file_path..[[.flac]] end From 6560f39c1d04721556624d6ca3b6f5d0a923e90d Mon Sep 17 00:00:00 2001 From: nemerald-voip Date: Wed, 31 Mar 2021 09:02:46 -0700 Subject: [PATCH 3/4] rebase file --- .../app/voicemail/resources/functions/record_message.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua b/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua index 8d8cd51031..7e0a52ef8d 100644 --- a/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua +++ b/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua @@ -281,7 +281,7 @@ if (transcribe_provider == "google") then local api_key = settings:get('voicemail', 'google_key', 'text') or ''; local transcription_server = settings:get('voicemail', 'google_url', 'text') or ''; - transcribe_alternate_language = settings:get('voicemail', 'transcribe_alternate_language', 'text') or 'es-US'; + if (api_key ~= '') then transcribe_cmd = [[sox ]]..file_path..[[ ]]..file_path..[[.flac trim 0 00:59 && echo "{ 'config': { 'languageCode': ']]..transcribe_language..[[', 'enableWordTimeOffsets': false , 'enableAutomaticPunctuation': true , 'alternativeLanguageCodes': ']]..transcribe_alternate_language..[[' }, 'audio': { 'content': '`base64 -w 0 ]]..file_path..[[.flac`' } }" | curl -X POST -H "Content-Type: application/json" -d @- "]]..transcription_server..[[:recognize?key=]]..api_key..[[" && rm -f ]]..file_path..[[.flac]] end From 65c80c7d5549e82423af356d09c313487faf79e2 Mon Sep 17 00:00:00 2001 From: nemerald-voip Date: Wed, 31 Mar 2021 16:33:54 -0700 Subject: [PATCH 4/4] Fix broken script --- .../app/voicemail/resources/functions/record_message.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua b/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua index 7e0a52ef8d..8d8cd51031 100644 --- a/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua +++ b/app/scripts/resources/scripts/app/voicemail/resources/functions/record_message.lua @@ -281,7 +281,7 @@ if (transcribe_provider == "google") then local api_key = settings:get('voicemail', 'google_key', 'text') or ''; local transcription_server = settings:get('voicemail', 'google_url', 'text') or ''; - + transcribe_alternate_language = settings:get('voicemail', 'transcribe_alternate_language', 'text') or 'es-US'; if (api_key ~= '') then transcribe_cmd = [[sox ]]..file_path..[[ ]]..file_path..[[.flac trim 0 00:59 && echo "{ 'config': { 'languageCode': ']]..transcribe_language..[[', 'enableWordTimeOffsets': false , 'enableAutomaticPunctuation': true , 'alternativeLanguageCodes': ']]..transcribe_alternate_language..[[' }, 'audio': { 'content': '`base64 -w 0 ]]..file_path..[[.flac`' } }" | curl -X POST -H "Content-Type: application/json" -d @- "]]..transcription_server..[[:recognize?key=]]..api_key..[[" && rm -f ]]..file_path..[[.flac]] end