Live API এর বেসিক ইমপ্লিমেন্টেশন ব্যবহার করেও আপনি আপনার ব্যবহারকারীদের জন্য আকর্ষণীয় ও শক্তিশালী ইন্টারঅ্যাকশন তৈরি করতে পারেন। নিম্নলিখিত কনফিগারেশন অপশনগুলো ব্যবহার করে আপনি চাইলে অভিজ্ঞতাটিকে আরও কাস্টমাইজ করতে পারেন:
প্রতিক্রিয়া কণ্ঠস্বর এবং ভাষা
আপনি মডেলটিকে একটি নির্দিষ্ট কণ্ঠস্বরে সাড়া দিতে বাধ্য করতে পারেন এবং বিভিন্ন ভাষায় সাড়া দেওয়ার জন্য তাকে প্রভাবিত করতে পারেন।
একটি প্রতিক্রিয়া কণ্ঠস্বর নির্দিষ্ট করুন
এই পৃষ্ঠায় প্রদানকারী-নির্দিষ্ট বিষয়বস্তু এবং কোড দেখতে আপনার জেমিনি এপিআই প্রদানকারীর উপর ক্লিক করুন। |
Live API এইচডি ভয়েসে সংশ্লেষিত বক্তৃতা প্রতিক্রিয়া সমর্থন করতে Chirp 3 ব্যবহার করে।
আপনি যদি কোনো প্রতিক্রিয়া কণ্ঠস্বর নির্দিষ্ট না করেন, তাহলে ডিফল্ট হিসেবে Puck ব্যবহৃত হয়।
প্রতিটি কণ্ঠস্বর শুনতে কেমন তার ডেমোর জন্য, Chirp 3: HD voices দেখুন।
Zephyr — উজ্জ্বলKore — দৃঢ়Orus — দৃঢ়Autonoe — BrightUmbriel — সহজ-সরলErinome — পরিষ্কারLaomedeia — উচ্ছ্বসিতSchedar — এমনকিAchird — বন্ধুত্বপূর্ণSadachbia — প্রাণবন্ত | Puck — উচ্ছ্বসিতFenrir — উত্তেজিতAoede — বাতাস বইছেEnceladus — শ্বাসপ্রশ্বাসযুক্তAlgieba — মসৃণAlgenib — গ্র্যাভেলিAchernar — নরমGacrux — পরিপক্কZubenelgenubi — CasualSadaltager — জ্ঞানী | 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-12-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-12-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-12-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-12-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-12-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-12-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 মডেলগুলো তাদের প্রতিক্রিয়ার জন্য স্বয়ংক্রিয়ভাবে উপযুক্ত ভাষা নির্বাচন করে।
| ভাষা | বিসিপি-৪৭ কোড | ভাষা | বিসিপি-৪৭ কোড |
|---|---|---|---|
| আরবি (মিশরীয়) | ar-EG | জার্মান (জার্মানি) | ডি-ডিই |
| ইংরেজি (মার্কিন যুক্তরাষ্ট্র) | en-US | স্প্যানিশ (মার্কিন যুক্তরাষ্ট্র) | es-US |
| ফরাসি (ফ্রান্স) | fr-FR | হিন্দি (ভারত) | হাই-ইন |
| ইন্দোনেশিয়ান (ইন্দোনেশিয়া) | আইডি-আইডি | ইতালীয় (ইতালি) | আইটি-আইটি |
| জাপানি (জাপান) | জা-জেপি | কোরিয়ান (কোরিয়া) | কো-কেআর |
| পর্তুগিজ (ব্রাজিল) | পিটি-বিআর | রাশিয়ান (রাশিয়া) | ru-RU |
| ডাচ (নেদারল্যান্ডস) | এনএল-এনএল | পোলিশ (পোল্যান্ড) | pl-PL |
| থাই (থাইল্যান্ড) | তম-টিএইচ | তুর্কি (তুরস্ক) | tr-TR |
| ভিয়েতনামী (ভিয়েতনাম) | ভি-ভিএন | রোমানিয়ান (রোমানিয়া) | ro-RO |
| ইউক্রেনীয় (ইউক্রেন) | ইউকে-ইউএ | বাংলা (বাংলাদেশ) | bn-BD |
| ইংরেজি (ভারত) | en-IN এবং hi-IN বান্ডেল | মারাঠি (ভারত) | মিঃ-আইএন |
| তামিল (ভারত) | তা-আইএন | তেলুগু (ভারত) | 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.
অডিও ইনপুট এবং আউটপুটের জন্য ট্রান্সক্রিপশন
এই পৃষ্ঠায় প্রদানকারী-নির্দিষ্ট বিষয়বস্তু এবং কোড দেখতে আপনার জেমিনি এপিআই প্রদানকারীর উপর ক্লিক করুন। |
মডেলের প্রতিক্রিয়ার অংশ হিসেবে, আপনি অডিও ইনপুট এবং মডেলের অডিও প্রতিক্রিয়ার ট্রান্সক্রিপশন পেতে পারেন। আপনি মডেল কনফিগারেশনের অংশ হিসেবে এই কনফিগারেশনটি সেট করেন।
অডিও ইনপুটের ট্রান্সক্রিপশনের জন্য,
inputAudioTranscriptionযোগ করুন।মডেলের অডিও প্রতিক্রিয়ার ট্রান্সক্রিপশনের জন্য,
outputAudioTranscriptionযোগ করুন।
নিম্নলিখিত বিষয়গুলো লক্ষ্য করুন:
আপনি মডেলটিকে ইনপুট এবং আউটপুট উভয়ের ট্রান্সক্রিপশন ফেরত দেওয়ার জন্য কনফিগার করতে পারেন (যেমনটি নিম্নলিখিত উদাহরণে দেখানো হয়েছে), অথবা আপনি এটিকে কেবল যেকোনো একটি ফেরত দেওয়ার জন্যও কনফিগার করতে পারেন।
অডিওর সাথে ট্রান্সক্রিপ্টগুলোও স্ট্রিম করা হয়, তাই প্রতিবারের পালা শেষে টেক্সট অংশের মতোই এগুলো সংগ্রহ করে নেওয়া ভালো।
অডিও ইনপুট এবং মডেলের অডিও প্রতিক্রিয়া থেকে ট্রান্সক্রিপশন ভাষাটি অনুমান করা হয়।
সুইফট
// ...
let liveModel = FirebaseAI.firebaseAI(backend: .googleAI()).liveModel(
modelName: "gemini-2.5-flash-native-audio-preview-12-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-12-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-12-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-12-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-12-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-12-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 ডিফল্টরূপে সক্রিয় থাকে।
সেশন ব্যবস্থাপনা
নিম্নলিখিত সেশন-সম্পর্কিত বিষয়গুলো সম্পর্কে জানুন:
উন্নত সক্ষমতা, যার মধ্যে রয়েছে:
সেশন-সম্পর্কিত সীমাবদ্ধতা , যার মধ্যে রয়েছে সংযোগ ও সেশন দৈর্ঘ্যের সীমাবদ্ধতা, সেশন কনটেক্সট উইন্ডোর সীমাবদ্ধতা এবং রেট লিমিট।
সেশন সীমা পরিচালনার বিকল্পসমূহ, যার মধ্যে রয়েছে: