Skip to content

This repository provides an example of using the Palabra API with TypeScript to perform real-time speech-to-speech translation from English to Spanish.

Notifications You must be signed in to change notification settings

PalabraAI/typescript-speech-to-speech-translation-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Real-Time Speech-to-Speech Translation

Real-Time Speech-to-Speech Translation with TypeScript

This repository demonstrates how to use the Palabra API for real-time speech-to-speech translation from English to Spanish using TypeScript (JavaScript).

It provides ~/src/main.ts file with clear and step-by-step code examples (relevant to the Palabra WebRTC Quick Start Guide). The repository allows to build the project locally with just a few simple commands, enabling you to experience real-time translation of your own speech directly in your browser.

Local Development

Prerequisites

  • Node 18+
  • pnpm

Build and Launch the local project

  • Clone the repository
  • Create a new .env file in the root directory of the project.
  • Add the Palabra Credentials to the following environment variables in the .env file:
VITE_PALABRA_CLIENT_ID=<Your_Client_ID>
VITE_PALABRA_CLIENT_SECRET=<Your_Client_Secret>
  • Run pnpm install
  • Run pnpm dev

The application will be available at http://localhost:5173/ by default.

Supported Languages

While this demo is pre-configurated to translate from English to Spanish, Palabra Palabra API supports a wide range of languages for speech recognition and translation:

Speech Recognition: 🇸🇦 Arabic, 🇨🇳 Chinese, 🇨🇿 Czech, 🇩🇰 Danish, 🇳🇱 Dutch, 🇬🇧 English, 🇫🇮 Finnish, 🇫🇷 French, 🇩🇪 German, 🇬🇷 Greek, 🇮🇱 Hebrew, 🇮🇳 Hindi, 🇭🇺 Hungarian, 🇮🇹 Italian, 🇯🇵 Japanese, 🇰🇷 Korean, 🇵🇱 Polish, 🇵🇹 Portuguese, 🇷🇺 Russian, 🇪🇸 Spanish, 🇹🇷 Turkish, 🇺🇦 Ukrainian

Translation: 🇸🇦 Arabic, 🇧🇬 Bulgarian, 🇨🇳 Chinese (Mandarin), 🇨🇳 Chinese (Cantonese), 🇨🇿 Czech, 🇩🇰 Danish, 🇳🇱 Dutch, 🇬🇧 English (United Kingdom), 🇺🇸 English (United States), 🇫🇮 Finnish, 🇫🇷 French, 🇩🇪 German, 🇬🇷 Greek, 🇮🇱 Hebrew, 🇮🇳 Hindi, 🇭🇺 Hungarian, 🇮🇩 Indonesian, 🇮🇹 Italian, 🇯🇵 Japanese, 🇰🇷 Korean, 🇵🇱 Polish, 🇵🇹 Portuguese, 🇵🇹 Portuguese (Brazilian), 🇷🇴 Romanian, 🇷🇺 Russian, 🇸🇰 Slovak, 🇪🇸 Spanish, 🇸🇪 Swedish, 🇹🇷 Turkish, 🇺🇦 Ukrainian

View the full language table.

Changing the languages in Demo

If you wish to change English-to-Spanish translation languages, check the @/src/config/translation.config.ts file. You can change the source_language and target_language values for any other supported language codes.

About

This repository provides an example of using the Palabra API with TypeScript to perform real-time speech-to-speech translation from English to Spanish.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published