DEV Community

César Freitas
César Freitas

Posted on

Generate Portuguese (and 8 more languages) speech via API

Generating speech in multiple languages can be a challenging task for developers. Whether you're creating a language learning app, a podcast, or simply want to add a voice to your chatbot, being able to produce natural-sounding speech is crucial.

The Multilingual Text-to-Speech API addresses this challenge by providing a solution that can convert text into natural speech in multiple languages. This API supports 9 languages, including Portuguese, and comes with 54 different voices, allowing for a wide range of options to choose from. The best part? The API returns both MP3 and WAV files in one request, making it easy to integrate into your project.

One of the key benefits of using this API is its flexibility. Because it supports multiple languages and voices, developers can easily switch between them to cater to different user needs or preferences. For example, a language learning app might use a neutral voice for general lessons, but switch to a more energetic voice when teaching colloquial expressions.

When making a request to the API, you'll typically need to provide some basic information about the text you want to convert into speech. This includes the text itself, as well as any other relevant details such as the target language and the desired audio format (MP3 or WAV). The response from the API will contain the generated speech in the requested format.

A typical request might look something like this: "I'd like to generate a 30-second voiceover of the following text in Portuguese, using a female voice with a neutral tone." The response from the API would then be a single file containing the generated speech, either as an MP3 or WAV file. This process can happen quickly and efficiently, making it easy to integrate into your project.

While this API is certainly powerful, it's worth noting that there are limitations to its use. For example, you may need to pay for usage above a certain limit (depending on the plan you choose), and some features may not be available in the free tier. However, even with these limitations, this API remains a valuable tool for developers looking to add speech capabilities to their projects.

If you're interested in trying out this API, we recommend checking it out on RapidAPI. They offer a free tier that's perfect for testing and prototyping, and can help you get started quickly and easily. Just be sure to check the pricing and usage limits before getting started, so you can plan accordingly. With its flexibility, range of options, and ease of use, this API is definitely worth considering for your next project.

Quick example

curl -X POST 'https://multilingual-text-to-speech2.p.rapidapi.com/v1/tts' \
  -H 'X-RapidAPI-Key: YOUR_RAPIDAPI_KEY' \
  -H 'X-RapidAPI-Host: multilingual-text-to-speech2.p.rapidapi.com' \
  -H 'Content-Type: application/json' \
  -d '{"text":"Hello world","voice":"af_alloy","format":"mp3"}'
Enter fullscreen mode Exit fullscreen mode

Try it: the Multilingual Text-to-Speech API is live on RapidAPI with a free tier — get your key here.

Top comments (0)