Live API এর মৌলিক বাস্তবায়নের পরেও, আপনি আপনার ব্যবহারকারীদের জন্য আকর্ষণীয় এবং শক্তিশালী ইন্টারঅ্যাকশন তৈরি করতে পারেন। আপনি ঐচ্ছিকভাবে নিম্নলিখিত কনফিগারেশন বিকল্পগুলি ব্যবহার করে অভিজ্ঞতাটিকে আরও কাস্টমাইজ করতে পারেন:
প্রতিক্রিয়ার কণ্ঠস্বর এবং ভাষা
আপনি মডেলটিকে একটি নির্দিষ্ট কণ্ঠে সাড়া দিতে পারেন এবং মডেলটিকে বিভিন্ন ভাষায় সাড়া দেওয়ার জন্য প্রভাবিত করতে পারেন।
একটি প্রতিক্রিয়া ভয়েস নির্দিষ্ট করুন
এই পৃষ্ঠায় প্রোভাইডার-নির্দিষ্ট কন্টেন্ট এবং কোড দেখতে আপনার জেমিনি API প্রোভাইডারে ক্লিক করুন। |
Live API এইচডি ভয়েসে সংশ্লেষিত বক্তৃতা প্রতিক্রিয়া সমর্থন করার জন্য Chirp 3 ব্যবহার করে।
যদি আপনি একটি প্রতিক্রিয়া ভয়েস নির্দিষ্ট না করেন, তাহলে ডিফল্ট হল Puck ।
প্রতিটি কণ্ঠস্বর কেমন শোনাচ্ছে তার ডেমোর জন্য, Chirp 3: HD কণ্ঠস্বর দেখুন।
Zephyr -- উজ্জ্বলKore -- ফার্মOrus -- ফার্মAutonoe -- উজ্জ্বলUmbriel -- শান্ত-সুলভErinome -- পরিষ্কারLaomedeia -- উচ্ছ্বসিতSchedar -- জোড়Achird -- বন্ধুত্বপূর্ণSadachbia -- প্রাণবন্ত | Puck -- উচ্ছ্বসিতFenrir -- উত্তেজনাপূর্ণAoede -- হাওয়ালাEnceladus -- শ্বাসরুদ্ধকরAlgieba -- মসৃণAlgenib -- গ্রেভেলিAchernar -- নরমGacrux -- পরিণতZubenelgenubi -- ক্যাজুয়ালSadaltager -- জ্ঞানী | Charon -- তথ্যবহুলLeda -- তরুণCallirrhoe -- আরামদায়কIapetus -- পরিষ্কারDespina -- মসৃণRasalgethi -- তথ্যবহুলAlnilam -- দৃঢ়Pulcherrima -- ফরোয়ার্ডVindemiatrix -- ভদ্রSulafat -- উষ্ণ |
একটি প্রতিক্রিয়া ভয়েস নির্দিষ্ট করতে, মডেল কনফিগারেশনের অংশ হিসাবে speechConfig অবজেক্টের মধ্যে ভয়েস নাম সেট করুন।
সুইফট
// ...
let liveModel = FirebaseAI.firebaseAI(backend: .googleAI()).liveModel(
modelName: "gemini-2.5-flash-native-audio-preview-09-2025",
// Configure the model to use a specific voice for its audio response
generationConfig: LiveGenerationConfig(
responseModalities: [.audio],
speech: SpeechConfig(voiceName: "VOICE_NAME")
)
)
// ...
Kotlin
// ...
val model = Firebase.ai(backend = GenerativeBackend.googleAI()).liveModel(
modelName = "gemini-2.5-flash-native-audio-preview-09-2025",
// Configure the model to use a specific voice for its audio response
generationConfig = liveGenerationConfig {
responseModality = ResponseModality.AUDIO
speechConfig = SpeechConfig(voice = Voice("VOICE_NAME"))
}
)
// ...
Java
// ...
LiveGenerativeModel lm = FirebaseAI.getInstance(GenerativeBackend.googleAI()).liveModel(
"gemini-2.5-flash-native-audio-preview-09-2025",
// Configure the model to use a specific voice for its audio response
new LiveGenerationConfig.Builder()
.setResponseModality(ResponseModality.AUDIO)
.setSpeechConfig(new SpeechConfig(new Voice("VOICE_NAME")))
.build()
);
// ...
Web
// ...
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
const liveModel = getLiveGenerativeModel(ai, {
model: "gemini-2.5-flash-native-audio-preview-09-2025",
// Configure the model to use a specific voice for its audio response
generationConfig: {
responseModalities: [ResponseModality.AUDIO],
speechConfig: {
voiceConfig: {
prebuiltVoiceConfig: { voiceName: "VOICE_NAME" },
},
},
},
});
// ...
Dart
// ...
final _liveModel = FirebaseAI.googleAI().liveGenerativeModel(
model: 'gemini-2.5-flash-native-audio-preview-09-2025',
// Configure the model to use a specific voice for its audio response
liveGenerationConfig: LiveGenerationConfig(
responseModalities: [ResponseModalities.audio],
speechConfig: SpeechConfig(voiceName: 'VOICE_NAME'),
),
);
// ...
ঐক্য
// ...
var liveModel = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetLiveModel(
modelName: "gemini-2.5-flash-native-audio-preview-09-2025",
// Configure the model to use a specific voice for its audio response
liveGenerationConfig: new LiveGenerationConfig(
responseModalities: new[] { ResponseModality.Audio },
speechConfig: SpeechConfig.UsePrebuiltVoice("VOICE_NAME")
)
);
// ...
প্রতিক্রিয়া ভাষাকে প্রভাবিত করুন
Live API মডেলগুলি স্বয়ংক্রিয়ভাবে তাদের প্রতিক্রিয়ার জন্য উপযুক্ত ভাষা বেছে নেয়।
| ভাষা | BCP-47 কোড | ভাষা | BCP-47 কোড |
|---|---|---|---|
| আরবি (মিশরীয়) | এআর-ইজি | জার্মান (জার্মানি) | ডি-ডি |
| ইংরেজি (মার্কিন) | en-US সম্পর্কে | স্প্যানিশ (মার্কিন) | মার্কিন যুক্তরাষ্ট্র |
| ফরাসি (ফ্রান্স) | fr-FR সম্পর্কে | হিন্দি (ভারত) | হাই-ইন |
| ইন্দোনেশিয়ান (ইন্দোনেশিয়া) | আইডি-আইডি | ইতালীয় (ইতালি) | এটি-আইটি |
| জাপানি (জাপান) | জা-জেপি | কোরিয়ান (কোরিয়া) | কো-কেআর |
| পর্তুগিজ (ব্রাজিল) | pt-BR সম্পর্কে | রাশিয়ান (রাশিয়া) | ru-RU |
| ডাচ (নেদারল্যান্ডস) | nl-NL সম্পর্কে | পোলিশ (পোল্যান্ড) | পিএল-পিএল |
| থাই (থাইল্যান্ড) | ম-ম | তুর্কি (তুরস্ক) | টিআর-টিআর |
| ভিয়েতনামী (ভিয়েতনাম) | ভিআই-ভিএন | রোমানিয়ান (রোমানিয়া) | ro-RO |
| ইউক্রেনীয় (ইউক্রেন) | যুক্তরাজ্য-ইউএ | বাংলা (বাংলাদেশ) | বিএন-বিডি |
| ইংরেজি (ভারত) | এন-ইন এবং হাই-ইন বান্ডেল | মারাঠি (ভারত) | মিস্টার-ইন |
| তামিল (ভারত) | টা-ইন | তেলেগু (ভারত) | te-IN সম্পর্কে |
যদি আপনি চান যে মডেলটি ইংরেজি নয় এমন কোনও ভাষায় অথবা সর্বদা একটি নির্দিষ্ট ভাষায় প্রতিক্রিয়া জানাক, তাহলে আপনি এই উদাহরণগুলির মতো সিস্টেম নির্দেশাবলী ব্যবহার করে মডেলের প্রতিক্রিয়াগুলিকে প্রভাবিত করতে পারেন:
একটি অ-ইংরেজি ভাষা উপযুক্ত হতে পারে এমন মডেলটিকে আরও শক্তিশালী করুন
Listen to the speaker carefully. If you detect a non-English language, respond in the language you hear from the speaker. You must respond unmistakably in the speaker's language.মডেলকে সর্বদা একটি নির্দিষ্ট ভাষায় উত্তর দিতে বলুন।
RESPOND IN LANGUAGE. YOU MUST RESPOND UNMISTAKABLY IN LANGUAGE.
অডিও ইনপুট এবং আউটপুটের জন্য ট্রান্সক্রিপশন
এই পৃষ্ঠায় প্রোভাইডার-নির্দিষ্ট কন্টেন্ট এবং কোড দেখতে আপনার জেমিনি API প্রোভাইডারে ক্লিক করুন। |
মডেলের প্রতিক্রিয়ার অংশ হিসেবে, আপনি অডিও ইনপুট এবং মডেলের অডিও প্রতিক্রিয়ার ট্রান্সক্রিপশন পেতে পারেন। আপনি এই কনফিগারেশনটি মডেল কনফিগারেশনের অংশ হিসেবে সেট করেন।
অডিও ইনপুট ট্রান্সক্রিপশনের জন্য,
inputAudioTranscriptionযোগ করুন।মডেলের অডিও প্রতিক্রিয়ার ট্রান্সক্রিপশনের জন্য,
outputAudioTranscriptionযোগ করুন।
নিম্নলিখিত বিষয়গুলি লক্ষ্য করুন:
আপনি মডেলটিকে ইনপুট এবং আউটপুট উভয়ের ট্রান্সক্রিপশন ফেরত দেওয়ার জন্য কনফিগার করতে পারেন (যেমনটি নিম্নলিখিত উদাহরণে দেখানো হয়েছে), অথবা আপনি এটিকে কেবল একটি বা অন্যটি ফেরত দেওয়ার জন্য কনফিগার করতে পারেন।
ট্রান্সক্রিপ্টগুলি অডিওর সাথে স্ট্রিম করা হয়, তাই প্রতিটি পালায় টেক্সটের অংশগুলি যেমন সংগ্রহ করেন, সেভাবেই সেগুলি সংগ্রহ করা ভালো।
অডিও ইনপুট এবং মডেলের অডিও প্রতিক্রিয়া থেকে ট্রান্সক্রিপশন ভাষা অনুমান করা হয়।
সুইফট
// ...
let liveModel = FirebaseAI.firebaseAI(backend: .googleAI()).liveModel(
modelName: "gemini-2.5-flash-native-audio-preview-09-2025",
// Configure the model to return transcriptions of the audio input and output
generationConfig: LiveGenerationConfig(
responseModalities: [.audio],
inputAudioTranscription: AudioTranscriptionConfig(),
outputAudioTranscription: AudioTranscriptionConfig()
)
)
var inputTranscript: String = ""
var outputTranscript: String = ""
do {
let session = try await liveModel.connect()
for try await response in session.responses {
if case let .content(content) = response.payload {
if let inputText = content.inputAudioTranscription?.text {
// Handle transcription text of the audio input
inputTranscript += inputText
}
if let outputText = content.outputAudioTranscription?.text {
// Handle transcription text of the audio output
outputTranscript += outputText
}
if content.isTurnComplete {
// Log the transcripts after the current turn is complete
print("Input audio: \(inputTranscript)")
print("Output audio: \(outputTranscript)")
// Reset the transcripts for the next turn
inputTranscript = ""
outputTranscript = ""
}
}
}
} catch {
// Handle error
}
// ...
Kotlin
// ...
val liveModel = Firebase.ai(backend = GenerativeBackend.googleAI()).liveModel(
modelName = "gemini-2.5-flash-native-audio-preview-09-2025",
// Configure the model to return transcriptions of the audio input and output
generationConfig = liveGenerationConfig {
responseModality = ResponseModality.AUDIO
inputAudioTranscription = AudioTranscriptionConfig()
outputAudioTranscription = AudioTranscriptionConfig()
}
)
val liveSession = liveModel.connect()
fun handleTranscription(input: Transcription?, output: Transcription?) {
input?.text?.let { text ->
// Handle transcription text of the audio input
println("Input Transcription: $text")
}
output?.text?.let { text ->
// Handle transcription text of the audio output
println("Output Transcription: $text")
}
}
liveSession.startAudioConversation(null, ::handleTranscription)
// ...
Java
// ...
ExecutorService executor = Executors.newFixedThreadPool(1);
LiveGenerativeModel lm = FirebaseAI.getInstance(GenerativeBackend.googleAI()).liveModel(
"gemini-2.5-flash-native-audio-preview-09-2025",
// Configure the model to return transcriptions of the audio input and output
new LiveGenerationConfig.Builder()
.setResponseModality(ResponseModality.AUDIO)
.setInputAudioTranscription(new AudioTranscriptionConfig())
.setOutputAudioTranscription(new AudioTranscriptionConfig())
.build()
);
LiveModelFutures liveModel = LiveModelFutures.from(lm);
ListenableFuture sessionFuture = liveModel.connect();
Futures.addCallback(sessionFuture, new FutureCallback() {
@Override
public void onSuccess(LiveSessionFutures ses) {
LiveSessionFutures session = ses;
session.startAudioConversation((Transcription input, Transcription output) -> {
if (input != null) {
// Handle transcription text of the audio input
System.out.println("Input Transcription: " + input.getText());
}
if (output != null) {
// Handle transcription text of the audio output
System.out.println("Output Transcription: " + output.getText());
}
return null;
});
}
@Override
public void onFailure(Throwable t) {
// Handle exceptions
t.printStackTrace();
}
}, executor);
// ...
Web
// ...
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
const liveModel = getLiveGenerativeModel(ai, {
model: 'gemini-2.5-flash-native-audio-preview-09-2025',
// Configure the model to return transcriptions of the audio input and output
generationConfig: {
responseModalities: [ResponseModality.AUDIO],
inputAudioTranscription: {},
outputAudioTranscription: {},
},
});
const liveSession = await liveModel.connect();
liveSession.sendAudioRealtime({ data, mimeType: "audio/pcm" });
const messages = liveSession.receive();
for await (const message of messages) {
switch (message.type) {
case 'serverContent':
if (message.inputTranscription) {
// Handle transcription text of the audio input
console.log(`Input transcription: ${message.inputTranscription.text}`);
}
if (message.outputTranscription) {
// Handle transcription text of the audio output
console.log(`Output transcription: ${message.outputTranscription.text}`);
} else {
// Handle other message types (modelTurn, turnComplete, interruption)
}
default:
// Handle other message types (toolCall, toolCallCancellation)
}
}
// ...
Dart
// ...
final _liveModel = FirebaseAI.googleAI().liveGenerativeModel(
model: 'gemini-2.5-flash-native-audio-preview-09-2025',
// Configure the model to return transcriptions of the audio input and output
liveGenerationConfig: LiveGenerationConfig(
responseModalities: [ResponseModalities.audio],
inputAudioTranscription: AudioTranscriptionConfig(),
outputAudioTranscription: AudioTranscriptionConfig(),
),
);
final LiveSession _session = _liveModel.connect();
await for (final response in _session.receive()) {
LiveServerContent message = response.message;
if (message.inputTranscription?.text case final inputText?) {
// Handle transcription text of the audio input
print('Input: $inputText');
}
if (message.outputTranscription?.text case final outputText?) {
// Handle transcription text of the audio output
print('Output: $outputText');
}
}
// ...
ঐক্য
// ...
var liveModel = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetLiveModel(
modelName: "gemini-2.5-flash-native-audio-preview-09-2025",
// Configure the model to return transcriptions of the audio input and output
liveGenerationConfig: new LiveGenerationConfig(
responseModalities: new[] { ResponseModality.Audio },
inputAudioTranscription: new AudioTranscriptionConfig(),
outputAudioTranscription: new AudioTranscriptionConfig()
)
);
try
{
var session = await liveModel.ConnectAsync();
var stream = session.ReceiveAsync();
await foreach (var response in stream) {
if (response.Message is LiveSessionContent sessionContent) {
if (!string.IsNullOrEmpty(sessionContent.InputTranscription?.Text)) {
// handle transcription text of input audio
}
if (!string.IsNullOrEmpty(sessionContent.OutputTranscription?.Text)) {
// handle transcription text of output audio
}
}
}
}
catch (Exception e)
{
// Handle error
}
// ...
ভয়েস অ্যাক্টিভিটি ডিটেকশন (VAD)
মডেলটি স্বয়ংক্রিয়ভাবে একটি অবিচ্ছিন্ন অডিও ইনপুট স্ট্রিমে ভয়েস অ্যাক্টিভিটি ডিটেকশন (VAD) সম্পাদন করে। VAD ডিফল্টরূপে সক্রিয় থাকে।
সেশন ব্যবস্থাপনা
নিম্নলিখিত সেশন-সম্পর্কিত বিষয়গুলি সম্পর্কে জানুন:
উন্নত ক্ষমতা, যার মধ্যে রয়েছে:
সেশন-সম্পর্কিত সীমা , যার মধ্যে রয়েছে সংযোগ এবং সেশনের দৈর্ঘ্যের সীমা, সেশনের প্রসঙ্গ উইন্ডো সীমা এবং হারের সীমা।
ফায়ারবেস এআই লজিক এখনও সেশন পরিচালনার জন্য নিম্নলিখিত বৈশিষ্ট্যগুলি সমর্থন করে না । শীঘ্রই আবার পরীক্ষা করুন!
- বাধাগুলি পরিচালনা করা
- সেশনের দৈর্ঘ্য বাড়ানো হচ্ছে
- একটি অধিবেশন পুনরায় শুরু করা হচ্ছে
- সেশন এবং অনুরোধ জুড়ে প্রেক্ষাপট বজায় রাখা
- প্রসঙ্গ উইন্ডো সংকুচিত করা হচ্ছে