On 24/9/23 06:46, Karen Lewellen wrote:
Hi folks,
Any tool in Debian, or another Linux application that will take audio
and translate that audio into English?
Have a friend who wishes to translate Armenian news broadcasts into
English, apparently not finding translations on the sites themselves.
thanks,
Karen
While not a current linux tool as such, openAI offers a speech to text
API that recognises Armenian and translates it to English
https://platform.openai.com/docs/guides/speech-to-text/quickstart
You can run the API as a a simple Python program on a Linux machine.
You do need to have an API account with openAI and it costs fractions of
a cent for each translation.
This is one python program written by GPT4 just now. I've used something
similar before, though there may be some limitation on audio file length
that requires chopping the input up to shorter lengths?
import openai
import sys
# Set your API key
openai.api_key = 'YOUR_API_KEY'
def translate_audio_to_english(filename):
with open(filename, "rb") as audio_file:
transcript = openai.Audio.translate("whisper-1", audio_file)
return transcript
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python script_name.py <path_to_audio_file>")
sys.exit(1)
audio_filename = sys.argv[1]
translated_text = translate_audio_to_english(audio_filename)
print(translated_text)
Then run it as
python3 translate_audio.py /path/to/file/armenian.mp3