elevenlabs / elevenlabs-js

The official JavaScript (Node) library for ElevenLabs Text to Speech.
https://elevenlabs.io
MIT License
60 stars 7 forks source link

Feature Request: Add Language Selection Capability to API for Inference #16

Open zolero opened 3 months ago

zolero commented 3 months ago

Feature Request

Summary:
The current version of the ElevenLabs API does not allow users to specify a language during inference. This feature would be incredibly beneficial for developers working on multilingual applications, ensuring that the generated output adheres to the desired language, especially in contexts where the input data might be ambiguous or multilingual.

Description:
In many applications, especially those handling user-generated content, the language of the input data can vary significantly. The ability to explicitly specify the target language for inference would enhance the API's flexibility and accuracy in generating appropriate responses. This is particularly crucial for applications serving global user bases across multiple languages.

Proposed Solution:
Introduce a new parameter in the API request for inference, named language, which allows developers to specify the desired language for the output. The parameter should accept ISO language codes (e.g., 'en' for English, 'fr' for French) and should be optional. If not specified, the API can default to its current behavior of inferring the language from the input data.

Example Usage with Proposed Feature:


import { ElevenLabsClient } from "elevenlabs";

const elevenlabs = new ElevenLabsClient({
  apiKey: "YOUR_API_KEY" // Defaults to process.env.ELEVENLABS_API_KEY
});

const audio = await elevenlabs.generate({
  voice: "Rachel",
  text: "Hello!",
  language: "en", // Specifying the language as English
  model_id: "eleven_multilingual_v2"
});
itinance commented 2 months ago

Such a setting to define the target language is definitely necessary. Auto-detection of the underlying language is not working properly and probably can't work for languages at all that use lots of anglicisms like many European languages.

See also #21