Gemini टीटीएस मॉडल को टेक्स्ट प्रॉम्प्ट से स्पीच (ऑडियो) आउटपुट जनरेट करने के लिए कहा जा सकता है. Firebase AI Logic का इस्तेमाल करके, सीधे अपने ऐप्लिकेशन से यह अनुरोध किया जा सकता है.
लिखे गए शब्दों को सुनने की सुविधा (टीटीएस) को कंट्रोल किया जा सकता है. इसका मतलब है कि आपको सटीक टेक्स्ट देना होगा, ताकि उसे बोली में बदला जा सके. इसके अलावा, ऑडियो आउटपुट की स्टाइल, लहजे, रफ़्तार, और टोन को कंट्रोल करने के लिए, प्रॉम्प्ट में नैचुरल लैंग्वेज का इस्तेमाल किया जा सकता है. टीटीएस को ट्रांसक्रिप्शन (बोली को लिखाई में बदलना) के उलट माना जा सकता है.
यह सुविधा, Gemini -tts के किसी भी मॉडल का इस्तेमाल करके उपलब्ध है. इन मॉडल को अच्छी क्वालिटी और कम इंतज़ार के साथ स्पीच जनरेट करने के लिए ऑप्टिमाइज़ किया गया है.
इस सुविधा की मदद से, ये काम किए जा सकते हैं:
इंटरैक्टिव स्टोरीटेलिंग: दिलचस्प ऑडियो बुक या रोल-प्लेइंग गेम बनाएं. इनमें मॉडल, अलग-अलग किरदारों के लिए आवाज़ें बदलता है या कहानी के हिसाब से अपनी टोन में बदलाव करता है. जैसे, सस्पेंस में फुसफुसाना या किसी चुटकुले पर हंसना.
भाषा सीखना: उच्चारण से जुड़ी ऐसी गाइड बनाएं जो टेक्स्ट को किसी खास क्षेत्रीय लहजे में या धीमी रफ़्तार से पढ़ सकें. इससे, सीखने वाले लोगों को मुश्किल उच्चारणों की प्रैक्टिस करने में मदद मिलेगी.
कॉन्टेंट के हिसाब से आवाज़ बदलने वाले रीडर: समाचार रिपोर्ट, रेसिपी या ब्लॉग पोस्ट को तेज़ आवाज़ में पढ़ें. इसके लिए, कॉन्टेंट के हिसाब से आवाज़ और इमोशन का इस्तेमाल करें. जैसे, ताज़ा खबर के लिए गंभीर आवाज़ या खाना बनाने के सिलसिलेवार निर्देशों के लिए गर्मजोशी और धैर्य वाली आवाज़.
इस गाइड में, टेक्स्ट इनपुट से स्पीच जनरेट करने का तरीका बताया गया है. इसमें एक या उससे ज़्यादा स्पीकर का इस्तेमाल किया जा सकता है. साथ ही, ऑडियो रिस्पॉन्स को स्ट्रीम करने का तरीका भी बताया गया है.
एक स्पीकर के लिए कोड पर जाएं एक से ज़्यादा स्पीकर के लिए कोड पर जाएं स्ट्रीम किए गए जवाबों के लिए कोड पर जाएं
Live API और टीटीएस के बीच तुलना
लिखे गए शब्दों को सुनने की सुविधा (टीटीएस) और Live API मॉडल, दोनों ही कम इंतज़ार के समय वाले मॉडल हैं. ये मॉडल, बोली जनरेट करते हैं. इन्हें अलग-अलग आवाज़ों और भाषाओं में जवाब देने के लिए कॉन्फ़िगर किया जा सकता है. हालांकि, दोनों का इस्तेमाल अलग-अलग कामों के लिए किया जाता है.
लिखे गए शब्दों को सुनने की सुविधा (टीटीएस), एकतरफ़ा, अनुरोध-जवाब इंटरैक्शन (टेक्स्ट इन, ऑडियो आउट) है. इसे ऐसे कामों के लिए डिज़ाइन किया गया है जिनमें दिए गए टेक्स्ट को हूबहू पढ़कर सुनाने की ज़रूरत होती है. साथ ही, इसमें स्टाइल और आवाज़ को बारीकी से कंट्रोल किया जा सकता है. जैसे, पॉडकास्ट में कहानी सुनाना, ऑडियो बुक बनाना या लेखों को तेज़ आवाज़ में पढ़कर सुनाना.
Live API जनरेशन में रीयल-टाइम में बोलकर बातचीत करने (बोलकर सवाल पूछना और बोलकर जवाब पाना) के लिए, दोनों तरफ़ से स्ट्रीमिंग की सुविधा उपलब्ध है. यह डाइनैमिक बातचीत के कॉन्टेक्स्ट में बेहतरीन तरीके से काम करता है. इसमें मॉडल यह तय करता है कि किस तरह की स्पीच का इस्तेमाल करना है. ध्यान दें कि Live API के नए मॉडल, वीडियो और इमेज इनपुट के साथ भी काम करते हैं.
शुरू करने से पहले
|
इस पेज पर, Gemini API की सेवा देने वाली कंपनी के हिसाब से कॉन्टेंट और कोड देखने के लिए, सेवा देने वाली कंपनी के नाम पर क्लिक करें. |
अगर आपने अब तक ऐसा नहीं किया है, तो शुरुआती निर्देश पढ़ें. इसमें Firebase प्रोजेक्ट सेट अप करने, अपने ऐप्लिकेशन को Firebase से कनेक्ट करने, और SDK टूल जोड़ने का तरीका बताया गया है. साथ ही, इसमें अपनी पसंद के Gemini API प्रोवाइडर के लिए बैकएंड सेवा को शुरू करने और GenerativeModel इंस्टेंस बनाने का तरीका भी बताया गया है.
अपने प्रॉम्प्ट को टेस्ट करने और उनमें बदलाव करने के लिए, हमारा सुझाव है कि आप Google AI Studio का इस्तेमाल करें.
इस सुविधा के साथ काम करने वाले मॉडल
gemini-3.1-flash-tts-preview
टेक्स्ट की मदद से बोली जनरेट करना
Gemini टीटीएस मॉडल का इस्तेमाल करके, दिए गए टेक्स्ट से बोली जनरेट की जा सकती है.
एक स्पीकर की आवाज़ में स्पीच जनरेट करना
|
इस सैंपल को आज़माने से पहले, इस गाइड में मौजूद शुरू करने से पहले सेक्शन को पूरा करें. इससे आपको अपना प्रोजेक्ट और ऐप्लिकेशन सेट अप करने में मदद मिलेगी. इस सेक्शन में, आपको Gemini API सेवा देने वाली कंपनी के लिए एक बटन पर भी क्लिक करना होगा, ताकि आपको इस पेज पर सेवा देने वाली कंपनी के हिसाब से कॉन्टेंट दिखे. |
मॉडल को इस तरह कॉन्फ़िगर किया जा सकता है कि वह सिर्फ़ एक आवाज़ में ऑडियो आउटपुट दे.
GenerationConfig में ये शामिल करें:
responseModalitiesकोAUDIOशामिल करने के लिए सेट करें.SpeechConfigको इनके साथ कॉन्फ़िगर करें:(ज़रूरी है) जवाब देने वाली आवाज़ का नाम (उदाहरण के लिए,
Kore)(ज़रूरी नहीं) भाषा कोड.
अगर आपने कोई भाषा नहीं चुनी है, तो Gemini टीटीएस मॉडल, प्रॉम्प्ट में मौजूद भाषा का अपने-आप पता लगा सकते हैं.
टेक्स्ट प्रॉम्प्ट की मदद से generateContent को कॉल करें. मॉडल, रिस्पॉन्स के हिस्सों में रॉ पीसीएम ऑडियो डेटा दिखाता है.
Swift
import FirebaseAILogic
// Initialize the Gemini Developer API backend service.
let ai = FirebaseAI.firebaseAI(backend: .googleAI())
// Set `responseModalities` to include `AUDIO`.
// Configure a `SpeechConfig` with your chosen voice name (and optionally a language code).
let config = GenerationConfig(
responseModalities: [.audio],
speechConfig: SpeechConfig(voiceName: "Kore", languageCode: "en-US")
)
// Create a `GenerativeModel` instance with a model that supports speech generation.
let model = ai.generativeModel(
modelName: "gemini-3.1-flash-tts-preview",
generationConfig: config
)
// Provide a text prompt.
let prompt = "Say cheerfully: Have a wonderful day!"
// Call `generateContent` to generate the speech output based on your text prompt.
let response = try await model.generateContent(prompt)
// Extract the audio data and handle it for downstream use. For example:
for part in response.inlineDataParts {
let data = part.data // Raw PCM audio bytes (24kHz, 1 channel, 16-bit)
let mimeType = part.mimeType // for example: "audio/pcm"
print("Received audio data with MIME type: \(mimeType)")
// To play back raw PCM audio bytes, you'll need to write your own `playRawPcm` function.
playRawPcm(data: data)
}
Kotlin
Kotlin के लिए, इस एसडीके में मौजूद तरीके, सस्पेंड फ़ंक्शन हैं. इन्हें Coroutine स्कोप से कॉल करना ज़रूरी है.
// Set `responseModalities` to include `AUDIO`.
// Configure a `SpeechConfig` with your chosen voice name (and optionally a language code).
val config = generationConfig {
responseModalities = listOf(ResponseModality.AUDIO)
speechConfig = SpeechConfig(
voice = Voice("Kore"),
languageCode = "en-US"
)
}
// Initialize the Gemini Developer API backend service.
val model = Firebase.ai(backend = GenerativeBackend.googleAI())
.generativeModel(
modelName = "gemini-3.1-flash-tts-preview",
generationConfig = config
)
// Provide a text prompt.
val prompt = "Say cheerfully: Have a wonderful day!"
// Call `generateContent` to generate the speech output based on your text prompt.
val response = model.generateContent(prompt)
// Extract the audio data and handle it for downstream use. For example:
val part = response.candidates.firstOrNull()?.content?.parts?.firstOrNull()
if (part is InlineDataPart) {
val pcmData = part.inlineData // Raw PCM bytes (24kHz, 1 channel, 16-bit)
val mimeType = part.mimeType // for example: "audio/pcm"
// To play back PCM audio data, you'll need to write your own `playAudio` function.
playAudio(pcmData)
}
Java
Java के लिए, इस एसडीके में मौजूद स्ट्रीमिंग के तरीके, Reactive Streams लाइब्रेरी सेPublisher टाइप दिखाते हैं.
// Set `responseModalities` to include `AUDIO`.
// Configure a `SpeechConfig` with your chosen voice name (and optionally a language code).
GenerationConfig config = new GenerationConfig.Builder()
.setResponseModalities(Collections.singletonList(ResponseModality.AUDIO))
.setSpeechConfig(new SpeechConfig(new Voice("Kore"), "en-US"))
.build();
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports speech generation.
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI())
.generativeModel("gemini-3.1-flash-tts-preview", config);
// Use the GenerativeModelFutures Java compatibility layer.
GenerativeModelFutures model = GenerativeModelFutures.from(ai);
// Provide a text prompt.
String prompt = "Say cheerfully: Have a wonderful day!";
Content content = new Content.Builder().addText(prompt).build();
Executor executor = Executors.newSingleThreadExecutor();
// Call `generateContent` to generate the speech output based on your text prompt.
// Extract the audio data and handle it for downstream use.
ListenableFuture<GenerateContentResponse> response = model.generateContent(content);
Futures.addCallback(response, new FutureCallback<GenerateContentResponse>() {
@Override
public void onSuccess(GenerateContentResponse result) {
Part part = result.getCandidates().get(0).getContent().getParts().get(0);
if (part instanceof InlineDataPart) {
byte[] pcmData = ((InlineDataPart) part).getInlineData();
String mimeType = ((InlineDataPart) part).getMimeType();
// To play back PCM audio data, you'll need to write your own `playAudio` function.
playAudio(pcmData);
}
}
@Override
public void onFailure(Throwable t) {
t.printStackTrace();
}
}, executor);
Web
import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, GoogleAIBackend, ResponseModality } from "firebase/ai";
// TODO(developer): Replace with your app's Firebase configuration
const firebaseConfig = { /* ... */ };
const firebaseApp = initializeApp(firebaseConfig);
// Initialize the Gemini Developer API backend service.
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Set `responseModalities` to include `AUDIO`.
// Configure a `SpeechConfig` with your chosen voice name (and optionally a language code).
const generationConfig = {
responseModalities: [ResponseModality.AUDIO],
speechConfig: {
voiceConfig: { prebuiltVoiceConfig: { voiceName: "Kore" } },
languageCode: "en-US"
}
};
// Create a `GenerativeModel` instance with a model that supports speech generation.
const model = getGenerativeModel(ai, {
model: "gemini-3.1-flash-tts-preview",
generationConfig
});
// Provide a text prompt.
const prompt = "Say cheerfully: Have a wonderful day!";
// Call `generateContent` to generate the speech output based on your text prompt.
const result = await model.generateContent(prompt);
const inlineDataParts = result.response.inlineDataParts();
// Extract the audio data and handle it for downstream use. For example:
if (inlineDataParts?.[0]) {
const pcmBase64 = inlineDataParts[0].inlineData.data;
// Decode base64 to ArrayBuffer
const pcmBuffer = Uint8Array.from(atob(pcmBase64), c => c.charCodeAt(0)).buffer;
// To play back a PCM buffer, you'll need to write your own `playAudio` function.
playAudio(pcmBuffer);
}
Dart
import 'package:firebase_ai/firebase_ai.dart';
// Set `responseModalities` to include `AUDIO`.
// Configure a `SpeechConfig` with your chosen voice name (and optionally a language code).
final config = GenerationConfig(
responseModalities: [ResponseModalities.audio],
speechConfig: SpeechConfig(voiceName: 'Kore', languageCode: 'en-US'),
);
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports speech generation.
final model = FirebaseAI.googleAI().generativeModel(
model: 'gemini-3.1-flash-tts-preview',
generationConfig: config,
);
// Provide a text prompt.
final prompt = 'Say cheerfully: Have a wonderful day!';
// Call `generateContent` to generate the speech output based on your text prompt.
final response = await model.generateContent([Content.text(prompt)]);
// Extract the audio data and handle it for downstream use. For example:
final part = response.candidates.first.content.parts.first;
if (part is InlineDataPart && part.mimeType.startsWith('audio/')) {
final Uint8List pcmData = part.bytes; // Raw PCM bytes (24kHz, 1 channel, 16-bit)
// To play back PCM audio data, you'll need to write your own `playAudio` function.
await playAudio(pcmData);
}
Unity
using Firebase.AI;
// Set `responseModalities` to include `Audio`.
// Configure a `SpeechConfig` with your chosen voice name and language code.
var config = new GenerationConfig(
responseModalities: new System.Collections.Generic.List<ResponseModality> { ResponseModality.Audio },
speechConfig: SpeechConfig.UsePrebuiltVoice("Kore", "en-US")
);
// Initialize the Gemini Developer API backend service.
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI());
// Create a `GenerativeModel` instance with a model that supports speech generation.
var model = ai.GetGenerativeModel(
modelName: "gemini-3.1-flash-tts-preview",
generationConfig: config
);
// Provide a text prompt.
var prompt = "Say cheerfully: Have a wonderful day!";
// Call `GenerateContentAsync` to generate the speech output based on your text prompt.
var response = await model.GenerateContentAsync(prompt);
// Extract the audio data and handle it for downstream use. For example:
if (response.Candidates.Count > 0) {
foreach (var part in response.Candidates[0].Content.Parts) {
if (part is ModelContent.InlineDataPart inlineData) {
byte[] pcmData = inlineData.Data; // Raw PCM bytes (24kHz, 1 channel, 16-bit)
// To play back PCM audio data, you'll need to write your own `playAudio` function.
playAudio(pcmData);
}
}
}
एक से ज़्यादा स्पीकर की आवाज़ में स्पीच जनरेट करना
|
इस सैंपल को आज़माने से पहले, इस गाइड में मौजूद शुरू करने से पहले सेक्शन को पूरा करें. इससे आपको अपना प्रोजेक्ट और ऐप्लिकेशन सेट अप करने में मदद मिलेगी. इस सेक्शन में, आपको Gemini API सेवा देने वाली कंपनी के लिए एक बटन पर भी क्लिक करना होगा, ताकि आपको इस पेज पर सेवा देने वाली कंपनी के हिसाब से कॉन्टेंट दिखे. |
मॉडल को इस तरह कॉन्फ़िगर किया जा सकता है कि वह टेक्स्ट में मौजूद अलग-अलग स्पीकर के लिए अलग-अलग आवाज़ों का इस्तेमाल करे. यह डायलॉग या बातचीत के लिए ऑडियो जनरेट करने में मददगार है.
एक
MultiSpeakerVoiceConfigबनाएं, जो स्पीकर के नामों (जिनका इस्तेमाल प्रॉम्प्ट में किया जाएगा) को जवाब देने वाली आवाज़ के नामों (उदाहरण के लिए,Kore) से मैप करे.मल्टी-स्पीकर कॉन्फ़िगरेशन में, सिर्फ़ दो स्पीकर इस्तेमाल किए जा सकते हैं.
GenerationConfigमें ये शामिल करें:responseModalitiesकोAUDIOशामिल करने के लिए सेट करें.SpeechConfigको इनके साथ कॉन्फ़िगर करें:(ज़रूरी है) अपना
MultiSpeakerVoiceConfigपास करें.(ज़रूरी नहीं) भाषा कोड.
अगर आपने कोई भाषा नहीं चुनी है, तो Gemini टीटीएस मॉडल, प्रॉम्प्ट में मौजूद भाषा का अपने-आप पता लगा सकते हैं.
अपने प्रॉम्प्ट में, बोलने वाले व्यक्ति का नाम प्रीफ़िक्स के तौर पर इस्तेमाल करें. उदाहरण के लिए,
Joe: Hello. Jane: Hi..
टेक्स्ट प्रॉम्प्ट की मदद से generateContent को कॉल करें. मॉडल, रिस्पॉन्स के हिस्सों में रॉ पीसीएम ऑडियो डेटा दिखाता है.
Swift
import FirebaseAILogic
// Initialize the Gemini Developer API backend service.
let ai = FirebaseAI.firebaseAI(backend: .googleAI())
// Configure a `SpeechConfig` for multiple speakers, assigning a voice to each speaker.
let multiSpeechConfig = SpeechConfig(
multiSpeakerVoiceConfig: MultiSpeakerVoiceConfig(
speakerVoiceConfigs: [
SpeakerVoiceConfig(speaker: "Joe", voiceName: "Puck"),
SpeakerVoiceConfig(speaker: "Jane", voiceName: "Kore")
]
),
languageCode: "en-US"
)
// Set `responseModalities` to include `audio`.
let config = GenerationConfig(
responseModalities: [.audio],
speechConfig: multiSpeechConfig
)
// Create a `GenerativeModel` instance with a model that supports speech generation.
let model = ai.generativeModel(
modelName: "gemini-3.1-flash-tts-preview",
generationConfig: config
)
// Provide a text prompt that includes the names of the speakers.
let prompt = """
Joe: How's it going today Jane?
Jane: Not too bad, how about you?
"""
// Call `generateContent` to generate the speech output based on your text prompt.
let response = try await model.generateContent(prompt)
// Extract the audio data and handle it for downstream use. For example:
for part in response.inlineDataParts {
let data = part.data // Raw PCM audio bytes (24kHz, 1 channel, 16-bit)
let mimeType = part.mimeType // for example: "audio/pcm"
print("Received audio data with MIME type: \(mimeType)")
// To play back raw PCM audio bytes, you'll need to write your own `playRawPcm` function.
playRawPcm(data: data)
}
Kotlin
Kotlin के लिए, इस एसडीके में मौजूद तरीके, सस्पेंड फ़ंक्शन हैं. इन्हें Coroutine स्कोप से कॉल करना ज़रूरी है.
// Configure a `SpeechConfig` for multiple speakers, assigning a voice to each speaker.
val multiSpeechConfig = SpeechConfig(
multiSpeakerVoiceConfig = MultiSpeakerVoiceConfig(
speakerVoiceConfigs = listOf(
SpeakerVoiceConfig(speaker = "Joe", voice = Voice("Puck")),
SpeakerVoiceConfig(speaker = "Jane", voice = Voice("Kore"))
)
),
languageCode = "en-US"
)
// Set `responseModalities` to include `AUDIO`.
val config = generationConfig {
responseModalities = listOf(ResponseModality.AUDIO)
speechConfig = multiSpeechConfig
}
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports speech generation.
val model = Firebase.ai(backend = GenerativeBackend.googleAI())
.generativeModel(
modelName = "gemini-3.1-flash-tts-preview",
generationConfig = config
)
// Provide a text prompt that includes the names of the speakers.
val prompt = """
Joe: How's it going today Jane?
Jane: Not too bad, how about you?
"""
// Call `generateContent` to generate the speech output based on your text prompt.
val response = model.generateContent(prompt)
// Extract the audio data and handle it for downstream use. For example:
val part = response.candidates.firstOrNull()?.content?.parts?.firstOrNull()
if (part is InlineDataPart) {
val pcmData = part.inlineData // Raw PCM bytes (24kHz, 1 channel, 16-bit)
val mimeType = part.mimeType // for example: "audio/pcm"
// To play back PCM audio data, you'll need to write your own `playAudio` function.
playAudio(pcmData)
}
Java
Java के लिए, इस एसडीके में मौजूद स्ट्रीमिंग के तरीके, Reactive Streams लाइब्रेरी सेPublisher टाइप दिखाते हैं.
// Configure a `SpeechConfig` for multiple speakers, assigning a voice to each speaker.
MultiSpeakerVoiceConfig multiSpeakerVoiceConfig = new MultiSpeakerVoiceConfig(
Arrays.asList(
new SpeakerVoiceConfig("Joe", new Voice("Puck")),
new SpeakerVoiceConfig("Jane", new Voice("Kore"))
)
);
SpeechConfig multiSpeechConfig = new SpeechConfig(multiSpeakerVoiceConfig);
// Set `responseModalities` to include `AUDIO`.
GenerationConfig config = new GenerationConfig.Builder()
.setResponseModalities(Collections.singletonList(ResponseModality.AUDIO))
.setSpeechConfig(multiSpeechConfig)
.build();
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports speech generation.
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI())
.generativeModel("gemini-3.1-flash-tts-preview", config);
GenerativeModelFutures model = GenerativeModelFutures.from(ai);
// Provide a text prompt that includes the names of the speakers.
String prompt = "Joe: How's it going today Jane?\nJane: Not too bad, how about you?";
Content content = new Content.Builder().addText(prompt).build();
Executor executor = Executors.newSingleThreadExecutor();
// Call `generateContent` to generate the speech output based on your text prompt.
// Extract the audio data and handle it for downstream use.
ListenableFuture<GenerateContentResponse> response = model.generateContent(content);
Futures.addCallback(response, new FutureCallback<GenerateContentResponse>() {
@Override
public void onSuccess(GenerateContentResponse result) {
Part part = result.getCandidates().get(0).getContent().getParts().get(0);
if (part instanceof InlineDataPart) {
byte[] pcmData = ((InlineDataPart) part).getInlineData(); // Raw PCM bytes (24kHz, 1 channel, 16-bit)
String mimeType = ((InlineDataPart) part).getMimeType(); // for example: "audio/pcm"
// To play back PCM audio data, you'll need to write your own `playAudio` function.
playAudio(pcmData);
}
}
@Override
public void onFailure(Throwable t) {
t.printStackTrace();
}
}, executor);
Web
import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, GoogleAIBackend, ResponseModality } from "firebase/ai";
// TODO(developer): Replace with your app's Firebase configuration
const firebaseConfig = { /* ... */ };
const firebaseApp = initializeApp(firebaseConfig);
// Initialize the Gemini Developer API backend service.
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Set `responseModalities` to include `AUDIO`.
// Configure a `SpeechConfig` for multiple speakers, assigning a voice to each speaker.
const generationConfig = {
responseModalities: [ResponseModality.AUDIO],
speechConfig: {
multiSpeakerVoiceConfig: {
speakerVoiceConfigs: [
{ speaker: "Joe", voiceConfig: { prebuiltVoiceConfig: { voiceName: "Puck" } } },
{ speaker: "Jane", voiceConfig: { prebuiltVoiceConfig: { voiceName: "Kore" } } }
]
},
languageCode: "en-US"
}
};
// Create a `GenerativeModel` instance with a model that supports speech generation.
const model = getGenerativeModel(ai, {
model: "gemini-3.1-flash-tts-preview",
generationConfig
});
// Provide a text prompt that includes the names of the speakers.
const prompt = `
Joe: How's it going today Jane?
Jane: Not too bad, how about you?
`;
// Call `generateContent` to generate the speech output based on your text prompt.
const result = await model.generateContent(prompt);
const inlineDataParts = result.response.inlineDataParts();
// Extract the audio data and handle it for downstream use. For example:
if (inlineDataParts?.[0]) {
const pcmBase64 = inlineDataParts[0].inlineData.data; // Raw PCM bytes (24kHz, 1 channel, 16-bit)
const pcmBuffer = Uint8Array.from(atob(pcmBase64), c => c.charCodeAt(0)).buffer;
// To play back a PCM buffer, you'll need to write your own `playAudio` function.
playAudio(pcmBuffer);
}
Dart
import 'package:firebase_ai/firebase_ai.dart';
// Configure a `SpeechConfig` for multiple speakers, assigning a voice to each speaker.
final multiSpeechConfig = SpeechConfig.multiSpeaker(
multiSpeakerVoiceConfig: MultiSpeakerVoiceConfig(
speakerVoiceConfigs: [
SpeakerVoiceConfig(speaker: 'Joe', voiceName: 'Puck'),
SpeakerVoiceConfig(speaker: 'Jane', voiceName: 'Kore'),
],
),
languageCode: 'en-US',
);
// Set `responseModalities` to include `audio`.
final config = GenerationConfig(
responseModalities: [ResponseModalities.audio],
speechConfig: multiSpeechConfig,
);
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports speech generation.
final model = FirebaseAI.googleAI().generativeModel(
model: 'gemini-3.1-flash-tts-preview',
generationConfig: config,
);
// Provide a text prompt that includes the names of the speakers.
final prompt = '''
Joe: How's it going today Jane?
Jane: Not too bad, how about you?
''';
// Call `generateContent` to generate the speech output based on your text prompt.
final response = await model.generateContent([Content.text(prompt)]);
// Extract the audio data and handle it for downstream use. For example:
final part = response.candidates.first.content.parts.first;
if (part is InlineDataPart && part.mimeType.startsWith('audio/')) {
final Uint8List pcmData = part.bytes; // Raw PCM bytes (24kHz, 1 channel, 16-bit)
// To play back PCM audio data, you'll need to write your own `playAudio` function.
await playAudio(pcmData);
}
Unity
using Firebase.AI;
// Configure a `SpeechConfig` for multiple speakers, assigning a voice to each speaker.
var multiSpeakerVoiceConfig = new MultiSpeakerVoiceConfig(
new System.Collections.Generic.List<SpeakerVoiceConfig> {
SpeakerVoiceConfig.UsePrebuiltVoice("Joe", "Puck"),
SpeakerVoiceConfig.UsePrebuiltVoice("Jane", "Kore")
}
);
var multiSpeechConfig = SpeechConfig.UseMultiSpeakerVoice(multiSpeakerVoiceConfig);
// Set `responseModalities` to include `Audio`.
var config = new GenerationConfig(
responseModalities: new System.Collections.Generic.List<ResponseModality> { ResponseModality.Audio },
speechConfig: multiSpeechConfig
);
// Initialize the Gemini Developer API backend service.
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI());
// Create a `GenerativeModel` instance with a model that supports speech generation.
var model = ai.GetGenerativeModel(
modelName: "gemini-3.1-flash-tts-preview",
generationConfig: config
);
// Provide a text prompt that includes the names of the speakers.
var prompt = "Joe: How's it going today Jane?\nJane: Not too bad, how about you?";
// Call `GenerateContentAsync` to generate the speech output based on your text prompt.
var response = await model.GenerateContentAsync(prompt);
// Extract the audio data and handle it for downstream use. For example:
if (response.Candidates.Count > 0) {
foreach (var part in response.Candidates[0].Content.Parts) {
if (part is ModelContent.InlineDataPart inlineData) {
byte[] pcmData = inlineData.Data; // Raw PCM bytes (24kHz, 1 channel, 16-bit)
// To play back PCM audio data, you'll need to write your own `playAudio` function.
playAudio(pcmData);
}
}
}
जवाब को स्ट्रीम करें
|
इस सैंपल को आज़माने से पहले, इस गाइड में मौजूद शुरू करने से पहले सेक्शन को पूरा करें. इससे आपको अपना प्रोजेक्ट और ऐप्लिकेशन सेट अप करने में मदद मिलेगी. इस सेक्शन में, आपको Gemini API सेवा देने वाली कंपनी के लिए एक बटन पर भी क्लिक करना होगा, ताकि आपको इस पेज पर सेवा देने वाली कंपनी के हिसाब से कॉन्टेंट दिखे. |
ऑडियो रिस्पॉन्स को जनरेट होते ही स्ट्रीम करके, तेज़ी से इंटरैक्शन किया जा सकता है और इंतज़ार का समय कम किया जा सकता है. इसके लिए, पूरी ऑडियो फ़ाइल के जनरेट होने का इंतज़ार करने की ज़रूरत नहीं है.
जनरेट की गई स्पीच की स्ट्रीमिंग, सिंगल-स्पीकर और मल्टी-स्पीकर, दोनों कॉन्फ़िगरेशन के लिए काम करती है. यह सुविधा सिर्फ़ Gemini 3.x TTS मॉडल इस्तेमाल करने पर काम करती है.
स्पीच रिस्पॉन्स को स्ट्रीम करने के लिए, generateContent के बजाय generateContentStream को कॉल करें. साथ ही, चंक के आते ही उन्हें हैंडल करें. यहां दिए गए उदाहरणों में, सिंगल-स्पीकर रिस्पॉन्स को स्ट्रीम करने का तरीका बताया गया है:
Swift
import FirebaseAILogic
// Initialize the Gemini Developer API backend service.
let ai = FirebaseAI.firebaseAI(backend: .googleAI())
// Set `responseModalities` to include `audio`.
// Configure a `SpeechConfig` with your chosen voice name (and optionally a language code).
let config = GenerationConfig(
responseModalities: [.audio],
speechConfig: SpeechConfig(voiceName: "Kore")
)
// Create a `GenerativeModel` instance with a model that supports speech generation.
let model = ai.generativeModel(
modelName: "gemini-3.1-flash-tts-preview",
generationConfig: config
)
// Provide a text prompt.
let prompt = "Tell me a story about a brave knight."
// Call `generateContentStream` to generate the speech output stream based on your text prompt.
let responseStream = try model.generateContentStream(prompt)
// Extract the audio data and handle it for downstream use. For example:
for try await chunk in responseStream {
for part in chunk.inlineDataParts {
let data = part.data // Raw PCM audio bytes (24kHz, 1 channel, 16-bit)
let mimeType = part.mimeType // for example: "audio/pcm"
// Append the audio chunk to your audio queue/buffer for playback.
appendAudioChunk(data)
}
}
Kotlin
Kotlin के लिए, इस एसडीके में मौजूद तरीके, सस्पेंड फ़ंक्शन हैं. इन्हें Coroutine स्कोप से कॉल करना ज़रूरी है.
// Set `responseModalities` to include `AUDIO`.
// Configure a `SpeechConfig` with your chosen voice name (and optionally a language code).
val config = generationConfig {
responseModalities = listOf(ResponseModality.AUDIO)
speechConfig = SpeechConfig(voice = Voice("Kore"))
}
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports speech generation.
val model = Firebase.ai(backend = GenerativeBackend.googleAI())
.generativeModel(
modelName = "gemini-3.1-flash-tts-preview",
generationConfig = config
)
// Provide a text prompt.
val prompt = "Tell me a story about a brave knight."
// Call `generateContentStream` to generate the speech output stream based on your text prompt.
// Extract the audio data and handle it for downstream use.
model.generateContentStream(prompt).collect { chunk ->
val part = chunk.candidates.firstOrNull()?.content?.parts?.firstOrNull()
if (part is InlineDataPart) {
val pcmChunk = part.inlineData // Raw PCM bytes (24kHz, 1 channel, 16-bit)
val mimeType = part.mimeType // for example: "audio/pcm"
// Append the audio chunk to your audio queue/buffer for playback.
appendAudioChunk(pcmChunk)
}
}
Java
Java के लिए, इस एसडीके में मौजूद स्ट्रीमिंग के तरीके, Reactive Streams लाइब्रेरी सेPublisher टाइप दिखाते हैं.
// Set `responseModalities` to include `AUDIO`.
// Configure a `SpeechConfig` with your chosen voice name (and optionally a language code).
GenerationConfig config = new GenerationConfig.Builder()
.setResponseModalities(Collections.singletonList(ResponseModality.AUDIO))
.setSpeechConfig(new SpeechConfig(new Voice("Kore")))
.build();
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports speech generation.
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI())
.generativeModel("gemini-3.1-flash-tts-preview", config);
GenerativeModelFutures model = GenerativeModelFutures.from(ai);
// Provide a text prompt.
String prompt = "Tell me a story about a brave knight.";
Content content = new Content.Builder().addText(prompt).build();
// Call `generateContentStream` to generate the speech output stream based on your text prompt.
Publisher<GenerateContentResponse> streamingResponse =
model.generateContentStream(content);
// Extract the audio data and handle it for downstream use.
streamingResponse.subscribe(new Subscriber<GenerateContentResponse>() {
@Override
public void onSubscribe(Subscription s) {
s.request(Long.MAX_VALUE);
}
@Override
public void onNext(GenerateContentResponse chunk) {
Part part = chunk.getCandidates().get(0).getContent().getParts().get(0);
if (part instanceof InlineDataPart) {
byte[] pcmChunk = ((InlineDataPart) part).getInlineData(); // Raw PCM bytes (24kHz, 1 channel, 16-bit)
String mimeType = ((InlineDataPart) part).getMimeType(); // for example: "audio/pcm"
// Append the audio chunk to your audio queue/buffer for playback.
appendAudioChunk(pcmChunk);
}
}
@Override
public void onComplete() {
// Audio stream complete.
}
@Override
public void onError(Throwable t) {
t.printStackTrace();
}
});
Web
import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, GoogleAIBackend, ResponseModality } from "firebase/ai";
// TODO(developer): Replace with your app's Firebase configuration
const firebaseConfig = { /* ... */ };
const firebaseApp = initializeApp(firebaseConfig);
// Initialize the Gemini Developer API backend service.
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
// Set `responseModalities` to include `AUDIO`.
// Configure a `SpeechConfig` with your chosen voice name (and optionally a language code).
const generationConfig = {
responseModalities: [ResponseModality.AUDIO],
speechConfig: {
voiceConfig: { prebuiltVoiceConfig: { voiceName: "Kore" } }
}
};
// Create a `GenerativeModel` instance with a model that supports speech generation.
const model = getGenerativeModel(ai, {
model: "gemini-3.1-flash-tts-preview",
generationConfig
});
// Provide a text prompt.
const prompt = "Tell me a story about a brave knight.";
// Call `generateContentStream` to generate the speech output stream based on your text prompt.
const result = await model.generateContentStream(prompt);
// Extract the audio data and handle it for downstream use. For example:
const playbackQueue = [];
for await (const chunk of result.stream) {
const inlineDataParts = chunk.inlineDataParts();
if (inlineDataParts?.[0]) {
const pcmBase64 = inlineDataParts[0].inlineData.data; // Raw PCM bytes (24kHz, 1 channel, 16-bit)
const pcmBuffer = Uint8Array.from(atob(pcmBase64), c => c.charCodeAt(0)).buffer;
// Append the audio chunk to your audio queue/buffer for playback.
playbackQueue.push(pcmBuffer);
}
}
// To play back an array of PCM buffers in sequence, you'll need to write your own `processPlaybackQueue` function.
processPlaybackQueue(playbackQueue);
Dart
import 'package:firebase_ai/firebase_ai.dart';
// Set `responseModalities` to include `audio`.
// Configure a `SpeechConfig` with your chosen voice name (and optionally a language code).
final config = GenerationConfig(
responseModalities: [ResponseModalities.audio],
speechConfig: SpeechConfig(voiceName: 'Kore'),
);
// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports speech generation.
final model = FirebaseAI.googleAI().generativeModel(
model: 'gemini-3.1-flash-tts-preview',
generationConfig: config,
);
// Provide a text prompt.
final prompt = 'Tell me a story about a brave knight.';
// Call `generateContentStream` to generate the speech output stream based on your text prompt.
final responseStream = model.generateContentStream([Content.text(prompt)]);
// Extract the audio data and handle it for downstream use. For example:
await for (final chunk in responseStream) {
final part = chunk.candidates.first.content.parts.first;
if (part is InlineDataPart && part.mimeType.startsWith('audio/')) {
final Uint8List pcmChunk = part.bytes; // Raw PCM bytes (24kHz, 1 channel, 16-bit)
// Append the audio chunk to your audio queue/buffer for playback.
appendAudioChunk(pcmChunk);
}
}
Unity
using System.Collections.Generic;
using System.Linq;
using Firebase.AI;
// Initialize the Gemini Developer API backend service.
var ai = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI());
// Set `ResponseModalities` to include `Audio`.
// Configure a `SpeechConfig` with your chosen voice name (and optionally a language code).
var config = new GenerationConfig(
responseModalities: new List<ResponseModality> { ResponseModality.Audio },
speechConfig: SpeechConfig.UsePrebuiltVoice("Kore")
);
// Create a `GenerativeModel` instance with a model that supports speech generation.
var model = ai.GetGenerativeModel(
modelName: "gemini-3.1-flash-tts-preview",
generationConfig: config
);
// Provide a text prompt.
var prompt = "Tell me a story about a brave knight.";
// Call `GenerateContentStreamAsync` to generate the speech output stream based on your text prompt.
var responseStream = model.GenerateContentStreamAsync(prompt);
// Extract the audio data and handle it for downstream use. For example:
await foreach (var response in responseStream)
{
var audioParts = response.Candidates.FirstOrDefault().Content.Parts
.OfType<ModelContent.InlineDataPart>();
foreach (var part in audioParts)
{
byte[] pcmChunk = part.Data; // Raw PCM bytes (24kHz, 1 channel, 16-bit)
// Append the audio chunk to your audio queue/buffer for playback.
appendAudioChunk(pcmChunk);
}
}
प्रॉम्प्ट की मदद से, बोलकर जवाब देने की सुविधा को कंट्रोल करना
प्रॉम्प्ट देने की खास तकनीकों का इस्तेमाल करके, जनरेट की गई स्पीच के टोन, रफ़्तार, और स्टाइल को कंट्रोल किया जा सकता है.
प्रॉम्प्ट के स्ट्रक्चर और ऑडियो टैग के बारे में यहां दिए गए सब-सेक्शन में, ज़्यादा जानकारी दी गई है. ज़्यादा जानकारी के लिए, प्रॉम्प्ट के लिए गाइड देखें.
प्रॉम्प्ट का स्ट्रक्चर
सबसे बेहतर नतीजे पाने के लिए, अपने प्रॉम्प्ट को इन कॉम्पोनेंट के साथ स्ट्रक्चर करें:
Audio Profile: स्पीकर के व्यक्तित्व, मुख्य पहचान, और आर्किटाइप के बारे में बताएं (उदाहरण के लिए,A warm, professional narrator).Scene: माहौल और इमोशनल वाइब के बारे में बताएं. उदाहरण के लिए,In a quiet libraryयाAmidst a noisy crowd.Director's Notes: आवाज़ के इमोशन, रफ़्तार, स्टाइल, और लहजे के बारे में बताएं. उदाहरण के लिए,Speak slowly and with mystery.Sample Context: मॉडल को शुरुआती जानकारी दें. उदाहरण के लिए,The speaker is greeting a close friend.ट्रांसक्रिप्ट: वह टेक्स्ट जिसे बोला जाना है. बेहतरीन परफ़ॉर्मेंस के लिए, पक्का करें कि टेक्स्ट की टोन और कॉन्टेक्स्ट, वॉइस प्रोफ़ाइल और डायरेक्टर के नोट से मेल खाते हों.
प्रॉम्प्ट का उदाहरण:
[Audio Profile: A young, energetic voice]
[Scene: A lively sports broadcast]
[Director's Notes: Speak fast, with high energy and excitement]
[Sample Context: The game just ended with a last-second touchdown]
Welcome back fans! What an incredible game we're witnessing today!
ऑडियो टैग
मॉडल की परफ़ॉर्मेंस को बेहतर बनाने के लिए, सीधे टेक्स्ट प्रॉम्प्ट में फ़ॉर्मैटिंग टैग डाले जा सकते हैं.
ऑडियो टैग सिर्फ़ Gemini 3.x TTS मॉडल का इस्तेमाल करने पर काम करते हैं.
आम तौर पर इस्तेमाल किए जाने वाले टैग में ये शामिल हैं:
[whispers]: धीरे-धीरे बोलना[laughs]: हंसी-मज़ाक़ के लिए[giggles]: हंसी-मज़ाक़ के लिए[sighs]: आह भरने की आवाज़ जोड़ने के लिए[gasp]: हांफने की आवाज़ जोड़ने के लिए[shouting]: चिल्लाना[excited]: उत्साह के साथ बोलने के लिए[serious]: गंभीर होकर बात करना[sighs whispers]: मिले-जुले इमोशन (टैग को आपस में जोड़ा जा सकता है)
ऑडियो टैग इस्तेमाल करते समय इन बातों का ध्यान रखें:
कोई पूरी सूची नहीं है: इस्तेमाल किए जा सकने वाले टैग की कोई तय सूची नहीं है. अलग-अलग भावनाओं और हाव-भाव (जैसे,
[bored],[sarcastically]या[like dracula]) के साथ एक्सपेरिमेंट करके देखें कि आउटपुट में क्या बदलाव होता है.अंग्रेज़ी के अलावा किसी अन्य भाषा में टेक्स्ट प्रॉम्प्ट: अगर आपका टेक्स्ट प्रॉम्प्ट अंग्रेज़ी में नहीं है, तो भी आपको बेहतर नतीजे पाने के लिए अंग्रेज़ी ऑडियो टैग इस्तेमाल करने चाहिए.
प्रॉम्प्ट का उदाहरण:
I have a secret to tell you. [whispers] I found the hidden treasure. [laughs] I can't believe it!
सीमाएं और ज़रूरी शर्तें
स्पीच जनरेशन की सुविधा का इस्तेमाल करते समय, इन सीमाओं और ज़रूरी शर्तों का ध्यान रखें:
मल्टी-स्पीकर कॉन्फ़िगरेशन में, सिर्फ़ दो स्पीकर इस्तेमाल किए जा सकते हैं.
Gemini 3.x TTS मॉडल का इस्तेमाल करने पर, सिर्फ़ ये सुविधाएं काम करती हैं: स्ट्रीमिंग, ऑडियो टैग, और अपने-आप पहचानी जाने वाली अन्य भाषाएं.
gemini-3.1-flash-tts-preview के लिए पाबंदियां
- आवाज़ में अंतर: ऐसा हो सकता है कि मॉडल का आउटपुट, चुने गए स्पीकर से हमेशा पूरी तरह से मैच न करे. ऐसा तब होता है, जब आपके प्रॉम्प्ट का टोन और कॉन्टेक्स्ट, स्पीकर की प्रोफ़ाइल से मैच न करे. उदाहरण के लिए, किसी पुरुष की भारी आवाज़ को किसी युवा लड़की की आवाज़ की तरह बोलने की कोशिश करना. पक्का करें कि आपके प्रॉम्प्ट का कॉन्टेक्स्ट, आवाज़ से मैच करता हो.
- लंबे आउटपुट: कुछ मिनट से ज़्यादा लंबे ऑडियो के लिए, बोली की क्वालिटी और निरंतरता में अंतर हो सकता है. हमारा सुझाव है कि लंबे टेक्स्ट प्रॉम्प्ट को छोटे-छोटे हिस्सों में बाँट लें.
- कभी-कभी टेक्स्ट टोकन मिलना: मॉडल कभी-कभी ऑडियो टोकन के बजाय टेक्स्ट टोकन दिखाता है. इस वजह से, अनुरोध पूरा नहीं हो पाता और
500गड़बड़ी का मैसेज दिखता है. ऐसा कुछ ही अनुरोधों में होता है. इसलिए, आपको अपने ऐप्लिकेशन में फिर से कोशिश करने का लॉजिक लागू करना चाहिए. - क्लासिफ़ायर की ओर से गलत तरीके से अस्वीकार किए गए अनुरोध: साफ़ तौर पर न दिए गए प्रॉम्प्ट की वजह से, स्पीच सिंथेसिस क्लासिफ़ायर काम नहीं कर सकता. इससे अनुरोध अस्वीकार हो सकता है (
PROHIBITED_CONTENT) या मॉडल, स्टाइल से जुड़े आपके निर्देशों को ज़ोर से पढ़ सकता है. इससे बचने के लिए, स्ट्रक्चर्ड प्रॉम्प्ट का इस्तेमाल करें. साथ ही, प्रॉम्प्ट की शुरुआत में साफ़ तौर पर प्रस्तावना (जैसे,Audio ProfileऔरDirector's Notes) शामिल करें.
Gemini Live की सुविधा के लिए उपलब्ध भाषाएँ और आवाज़ें
Gemini टीटीएस मॉडल, टेक्स्ट इनपुट लेते हैं और ऑडियो आउटपुट जनरेट करते हैं. इसलिए, जवाब में सिंथेटिक स्पीच ही मिलती है. यहां दिए गए सब-सेक्शन में, उन भाषाओं और आवाज़ों की सूची दी गई है जिनका इस्तेमाल Gemini टीटीएस मॉडल, "बोलने" (या जवाब देने) के लिए कर सकते हैं.
ये आवाज़ें कई भाषाओं में उपलब्ध हैं. इसका मतलब है कि एक ही आवाज़ का इस्तेमाल करके, किसी भी भाषा में स्पीच जनरेट की जा सकती है. उदाहरण के लिए, आवाज़ को Kore पर सेट किया जा सकता है. साथ ही, स्पैनिश, हिन्दी, और वियतनामीज़ में टेक्स्ट प्रॉम्प्ट भेजे जा सकते हैं. जवाब, कोर की आवाज़ में ही होंगे, लेकिन हर भाषा में अलग-अलग होंगे.
आवाज़ों के नाम
Gemini टीटीएस मॉडल, 30 अलग-अलग सिंथसाइज़्ड एचडी आवाज़ों के साथ काम करते हैं. हर आवाज़ की अपनी अलग विशेषताएं होती हैं. नीचे दिए गए सेक्शन को बड़ा करके, जवाब देने के लिए उपलब्ध आवाज़ों की सूची देखी जा सकती है और हर आवाज़ का डेमो सुना जा सकता है.
भाषाएं
Gemini के टीटीएस मॉडल, आपके टेक्स्ट प्रॉम्प्ट में मौजूद इन भाषाओं का अपने-आप पता लगा सकते हैं. जनरेट की गई स्पीच उसी भाषा में होगी.
ध्यान दें कि आपके पास स्पीच कॉन्फ़िगरेशन में, भाषा का कोड साफ़ तौर पर सेट करने का विकल्प होता है.
ऑडियो जनरेट करने वाले सभी मॉडल के साथ काम करने वाली भाषाएं
| भाषा | BCP-47 कोड | भाषा | BCP-47 कोड |
|---|---|---|---|
| ऐरेबिक (मिस्र) | ar-EG | जर्मन (जर्मनी) | de-DE |
| अंग्रेज़ी (यूएस) | en-US | स्पेनिश (यूएस) | es-US |
| फ़्रांसीसी (फ़्रांस) | fr-FR | हिन्दी (भारत) | hi-IN |
| इंडोनेशियन (इंडोनेशिया) | id-ID | इतालवी (इटली) | it-IT |
| जैपनीज़ (जापान) | ja-JP | कोरियन (कोरिया) | ko-KR |
| पॉर्चुगीज़ (ब्राज़ील) | pt-BR | रूसी (रूस) | ru-RU |
| डच (नीदरलैंड्स) | nl-NL | पोलिश (पोलैंड) | pl-PL |
| थाई (थाईलैंड) | th-TH | टर्किश (तुर्की) | tr-TR |
| वियतनामीज़ (वियतनाम) | vi-VN | रोमेनियन (रोमानिया) | ro-RO |
| यूक्रेनियन (यूक्रेन) | uk-UA | बांग्ला (बांग्लादेश) | bn-BD |
| अंग्रेज़ी (भारत) | en-IN और hi-IN बंडल | मराठी (भारत) | mr-IN |
| तमिल (भारत) | ta-IN | तेलुगु (भारत) | te-IN |
ऑडियो जनरेट करने वाले 3.x मॉडल के साथ काम करने वाली अन्य भाषाएँ
| भाषा | BCP-47 कोड | भाषा | BCP-47 कोड |
|---|---|---|---|
| अफ़्रीकान्स | af | फ़िलिपिनो | fil |
| अल्बेनियन | sq | फ़िनिश | fi |
| ऐमहैरिक | am | गैलिशियन | gl |
| आर्मीनियन | hy | जॉर्जियन | ka |
| अज़रबैजानी | az | ग्रीक | el |
| बैस्क | eu | गुजराती | gu |
| Belarusian | be | हैतियन क्रियोल | ht |
| बल्गैरियन | bg | हीब्रू | he |
| बर्मीज़ | my | हंगेरियन | hu |
| कैटलैन | ca | आइसलैंडिक | है |
| सेबुआनो | ceb | जावानीज़ | jv |
| चाइनीज़, मैंडरिन | cmn | कन्नड़ | kn |
| क्रोएशियन | घंटा | कोंकणी | kok |
| चेक | cs | लाओ | lo |
| डेनिश | da | लैटिन | la |
| एस्टोनियन | et | लातवियन | lv |
| Lithuanian | lt | लक्ज़मबर्गिश | पाउंड |
| मेसिडोनियन | mk | मैथिली | mai |
| मालागासी | मि॰ग्रा॰ | मलय | ms |
| Malayalam | ml | मंगोलियन | mn |
| Nepali | ne | नॉर्वीजन, बुकमॉल | nb |
| नॉर्वेजियन, निनॉर्स्क | nn | ओड़िया | या |
| पश्तो | ps | फ़ारसी | fa |
| पंजाबी | pa | सर्बियन | sr |
| सिंधी | sd | सिंहला | si |
| Slovak | sk | Slovenian | sl |
| स्वाहिली | sw | Swedish | sv |
| उर्दू | ur |
(ज़रूरी नहीं) भाषा कोड को साफ़ तौर पर सेट करना
अगर आपने स्पीच कॉन्फ़िगरेशन में भाषा का कोड नहीं दिया है, तो मॉडल आपके टेक्स्ट प्रॉम्प्ट में भाषा का अपने-आप पता लगा लेता है.
हालांकि, आपके पास साफ़ तौर पर भाषा सेट करने का विकल्प होता है. इसके लिए, स्पीच कॉन्फ़िगरेशन में languageCode पैरामीटर का इस्तेमाल करें. इसके लिए, आपको इनमें से किसी एक BCP-47 भाषा कोड का इस्तेमाल करना होगा:
- ऐरेबिक:
ar-XA - बांग्ला:
bn-IN - चाइनीज़ (मैंडरिन):
cmn-CN - डच:
nl-NL - अंग्रेज़ी:
en-US,en-GB,en-AU,en-IN - फ़्रेंच:
fr-FR,fr-CA - जर्मन:
de-DE - गुजराती:
gu-IN - हिन्दी:
hi-IN - इंडोनेशियन:
id-ID - इटैलियन:
it-IT - जापानी:
ja-JP - कन्नड़:
kn-IN - कोरियन:
ko-KR - मलयालम:
ml-IN - मराठी:
mr-IN - पोलिश:
pl-PL - पॉर्चुगीज़:
pt-BR - रशियन:
ru-RU - स्पैनिश:
es-US,es-ES - तमिल:
ta-IN - तेलुगू:
te-IN - थाई:
th-TH - टर्किश:
tr-TR - वियतनामी:
vi-VN
तुम और क्या कर सकती हो?
- मॉडल को लंबे प्रॉम्प्ट भेजने से पहले, टोकन की गिनती करने का तरीका जानें.
-
प्रोडक्शन की तैयारी शुरू करें. इसके लिए, प्रोडक्शन चेकलिस्ट देखें:
- Firebase App Check को जल्द से जल्द लागू करें, ताकि Gemini API को बिना अनुमति वाले क्लाइंट के गलत इस्तेमाल से बचाया जा सके.
- Firebase Remote Config या सर्वर प्रॉम्प्ट टेंप्लेट का इस्तेमाल करें, ताकि आप अपने ऐप्लिकेशन का नया वर्शन रिलीज़ किए बिना, एआई की सुविधा (जैसे, मॉडल का नाम) के कॉन्फ़िगरेशन में मांग पर बदलाव कर सकें.
अन्य सुविधाएं आज़माना
- सिलसिलेवार बातचीत (चैट) की सुविधा बनाएं.
- सिर्फ़ टेक्स्ट वाले प्रॉम्प्ट से टेक्स्ट जनरेट करना.
- टेक्स्ट और मल्टीमोडल प्रॉम्प्ट, दोनों से JSON जैसा स्ट्रक्चर्ड आउटपुट जनरेट करना.
- टेक्स्ट और टेक्स्ट, इमेज वग़ैरह का एक साथ इस्तेमाल करके प्रॉम्प्ट डालकर, इमेज जनरेट करना और उनमें बदलाव करना.
- Gemini Live API का इस्तेमाल करके, इनपुट और आउटपुट को स्ट्रीम करना (इसमें ऑडियो भी शामिल है).
-
Gemini मॉडल को अपने ऐप्लिकेशन के अन्य हिस्सों, बाहरी सिस्टम, और जानकारी से कनेक्ट करने के लिए, टूल इस्तेमाल करें. जैसे, फ़ंक्शन कॉलिंग और
Google Search याGoogle Maps के साथ ग्राउंडिंग.
कॉन्टेंट जनरेट करने की सुविधा को कंट्रोल करने का तरीका जानें
- प्रॉम्प्ट डिज़ाइन करने के बारे में जानें. इसमें सबसे सही तरीके, रणनीतियां, और प्रॉम्प्ट के उदाहरण शामिल हैं.
- मॉडल के पैरामीटर कॉन्फ़िगर करें. जैसे, ज़्यादा से ज़्यादा आउटपुट टोकन, बार-बार मिलने वाले आउटपुट टोकन की संभावना वगैरह.
- सुरक्षा सेटिंग का इस्तेमाल करें, ताकि नुकसान पहुंचाने वाले जवाब मिलने की संभावना को कम किया जा सके.
इस्तेमाल किए जा सकने वाले मॉडल के बारे में ज़्यादा जानें
अलग-अलग कामों के लिए उपलब्ध मॉडल, उनके कोटा, और कीमत के बारे में जानें.Firebase AI Logic के साथ अपने अनुभव के बारे में सुझाव/राय देना या शिकायत करना