What is Google Cloud API for TTS (Text to Speech)?

12,199

Solution 1

Google Text-to-Speech is a screen reader application developed and available on the Android platform, it is currently not available as part of the Google Cloud Platform.

On the other hand, Google Translate is split between a website add-on and a web based application possesing a feature called “Listen”. This feature can be used to play via audito the output of the translation, but it is currently not possible to download it in MP3 format.

It is important not to confuse the Cloud Translation API available as part of the Cloud Platform and serving to translate text-based input from one supported language to another.

Lastly, if you are interested to see this type of API available as part of the Google Cloud Platform, you can submit a new Feature Request Issue on this Google Public Issue Tracker.

Solution 2

Google recently published Google Cloud Text To Speech API.

.NET Client version of Google.Cloud.TextToSpeech can be found here: https://github.com/jhabjan/Google.Cloud.TextToSpeech.V1

Here is short example how to use the client:

GoogleCredential credentials =
    GoogleCredential.FromFile(Path.Combine(Program.AppPath, "jhabjan-test-47a56894d458.json"));

TextToSpeechClient client = TextToSpeechClient.Create(credentials);

SynthesizeSpeechResponse response = client.SynthesizeSpeech(
    new SynthesisInput()
    {
        Text = "Google Cloud Text-to-Speech enables developers to synthesize natural-sounding speech with 32 voices"
    },
    new VoiceSelectionParams()
    {
        LanguageCode = "en-US",
        Name = "en-US-Wavenet-C"
    },
    new AudioConfig()
    {
        AudioEncoding = AudioEncoding.Mp3
    }
);

string speechFile = Path.Combine(Directory.GetCurrentDirectory(), "sample.mp3");

File.WriteAllBytes(speechFile, response.AudioContent);
Share:
12,199
Admin
Author by

Admin

Updated on June 19, 2022

Comments

  • Admin
    Admin almost 2 years

    In my webapp, I'm trying to call make an HTTP request to a Google API which takes some text (such as "Hello World") and returns a MP3 file with the speech equivalent.

    I have seen this question: Google text to speech tts api doesn't seems to work. And this google page: https://cloud.google.com/translate/docs/.

    And there are lots of other pages that seem out of date -- it looks like this feature has been removed by google or is under a different rest call?

    I don't see any documentation (such as in Google Translate API https://cloud.google.com/translate/) on how to call the google api for TTS. I have a google cloud API account and key.

    Thanks, Dan