Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Error while trying to use the MediaTranslation API

Hi, I am trying to test the Media Translation API to translate a file called audio.wav with the code provided at https://github.com/googleapis/python-media-translation/blob/main/samples/snippets/translate_from_fil... but when I run it I get this result:

MiguelCh_0-1681356096352.png

Can anyone tell me what can be the problem?

I have previously used the audio.raw file and it worked fine, the problem is when I try to use the audio.wav file.

1 2 209
2 REPLIES 2

Hi @MiguelCh,

Welcome Back to Google Cloud Community.

Based on your investigation here are some possible answers for your come across errors:

  • Make sure the audio file's size is within the restrictions set by the MediaTranslation API, which has a 1 GB maximum file size limit. If the file size exceeds this threshold, you might need to divide it into smaller pieces and process each one separately.
  • Make sure you have the proper access rights to the audio file and are authenticated to use the MediaTranslation API.
  • Check the audio file's encoding. Both 32-bit floating point PCM and 16-bit signed integer PCM audio files are supported by the MediaTranslation API. You might need to encode the audio file if it is in a different format in order for it to work.

  • Verify that the audio file is in one of the MediaTranslation API's supported formats, which include FLAC, WAV, and MP3 (according to the specification). You may need to convert the audio file to one of these formats if it isn't already.

  • Verify that you are making the appropriate API request parameters and that you are adhering to the API documentation.

Here are some references that might help you.
https://cloud.google.com/translate/media/docs/basics
https://cloud.google.com/translate/media/docs

Hello, thank you for replying.
- The audio file I am trying to translate has a duration of 3:35 minutes and a weight of 1.6MB.
- Yes I have the access rights and I am authenticated to use the MediaTranslation API.
- I have used the FFmpeg tool to convert the audio.mp3 file to 16-bit signed PCM with the following command: ffmpeg -i audio.mp3 -c:a pcm_s16le audio.wav.

I have also verified that my file contains valid audio with ffprobe and I understand that it does:

MiguelCh_0-1681445397695.png

The code I am using looks like this:

MiguelCh_1-1681445694417.png

MiguelCh_2-1681445833201.png

And when executed this is what is displayed:

MiguelCh_3-1681446069641.png

Thank you very much for any help you can give me.