Live API için temel uygulamayla bile kullanıcılarınız için ilgi çekici ve güçlü etkileşimler oluşturabilirsiniz. İsterseniz aşağıdaki yapılandırma seçeneklerini kullanarak deneyimi daha da özelleştirebilirsiniz:
Ses Etkinliği Algılama (VAD) (ör. kesintileri yönetmek için)
Yanıt sesi ve dili
Modelin belirli bir sesle yanıt vermesini sağlayabilir ve modeli farklı dillerde yanıt vermesi için etkileyebilirsiniz.
Yanıt sesini belirtme
|
Bu sayfada sağlayıcıya özel içerikleri ve kodları görüntülemek için Gemini API sağlayıcınızı tıklayın. |
Live API, her biri farklı özelliklere sahip 30 farklı sentezlenmiş HD sesi destekler. Aşağıdaki bölümü genişleterek yanıt sesi seçeneklerinin listesini görüntüleyebilir ve her sesin demosunu dinleyebilirsiniz.
Yanıt sesi belirtmezseniz varsayılan olarak Puck kullanılır.
Yanıt sesini belirtmek için model yapılandırmasının bir parçası olarak speechConfig nesnesinde ses adını ayarlayın.
Swift
// ...
let liveModel = FirebaseAI.firebaseAI(backend: .googleAI()).liveModel(
modelName: "GEMINI_LIVE_API_MODEL_NAME",
// 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_LIVE_API_MODEL_NAME",
// 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_LIVE_API_MODEL_NAME",
// 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_LIVE_API_MODEL_NAME",
// 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_LIVE_API_MODEL_NAME',
// Configure the model to use a specific voice for its audio response.
liveGenerationConfig: LiveGenerationConfig(
responseModalities: [ResponseModalities.audio],
speechConfig: SpeechConfig(voiceName: 'VOICE_NAME'),
),
);
// ...
Unity
// ...
var liveModel = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetLiveModel(
modelName: "GEMINI_LIVE_API_MODEL_NAME",
// Configure the model to use a specific voice for its audio response
liveGenerationConfig: new LiveGenerationConfig(
responseModalities: new[] { ResponseModality.Audio },
speechConfig: SpeechConfig.UsePrebuiltVoice("VOICE_NAME")
)
);
// ...
Yanıt dilini etkileme
Live API modelleri, yanıtları için uygun dili otomatik olarak seçer.
Modelin İngilizce dışında bir dilde veya her zaman belirli bir dilde yanıt vermesini istiyorsanız aşağıdaki örneklerde olduğu gibi sistem talimatlarını kullanarak modelin yanıtlarını etkileyebilirsiniz:
Modele, İngilizce dışındaki bir dilin uygun olabileceğini hatırlatın.
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.Modele her zaman belirli bir dilde yanıt vermesini söyleme
RESPOND IN LANGUAGE. YOU MUST RESPOND UNMISTAKABLY IN LANGUAGE.
Ses girişi ve çıkışı için transkriptler
|
Bu sayfada sağlayıcıya özel içerikleri ve kodları görüntülemek için Gemini API sağlayıcınızı tıklayın. |
Modelin yanıtı kapsamında, ses girişinin ve modelin sesli yanıtının transkriptlerini alabilirsiniz. Bu yapılandırmayı model yapılandırmasının bir parçası olarak ayarlarsınız.
Ses girişinin transkripti için
inputAudioTranscriptionekleyin.Modelin sesli yanıtının transkripti için
outputAudioTranscriptionekleyin.
Aşağıdakileri göz önünde bulundurun:
Modeli, hem giriş hem de çıkışın transkriptlerini döndürecek şekilde (aşağıdaki örnekte gösterildiği gibi) veya yalnızca birini ya da diğerini döndürecek şekilde yapılandırabilirsiniz.
Transkriptler sesle birlikte aktarıldığından, her sıradaki metin parçaları gibi toplanmaları en iyisidir.
Metne dönüştürme dili, ses girişinden ve modelin sesli yanıtından tahmin edilir.
Swift
// ...
let liveModel = FirebaseAI.firebaseAI(backend: .googleAI()).liveModel(
modelName: "GEMINI_LIVE_API_MODEL_NAME",
// 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_LIVE_API_MODEL_NAME",
// 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_LIVE_API_MODEL_NAME",
// 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<LiveSessionFutures> sessionFuture = liveModel.connect();
Futures.addCallback(sessionFuture, new FutureCallback<LiveSessionFutures>() {
@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_LIVE_API_MODEL_NAME',
// 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_LIVE_API_MODEL_NAME',
// Configure the model to return transcriptions of the audio input and output.
liveGenerationConfig: LiveGenerationConfig(
responseModalities: [ResponseModalities.audio],
inputAudioTranscription: AudioTranscriptionConfig(),
outputAudioTranscription: AudioTranscriptionConfig(),
),
);
final LiveSession _session = await _liveModel.connect();
await for (final response in _session.receive()) {
if (response.message case LiveServerContent 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');
}
}
}
// ...
Unity
// ...
var liveModel = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetLiveModel(
modelName: "GEMINI_LIVE_API_MODEL_NAME",
// 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
}
// ...
Ses Etkinliği Algılama (VAD)
Ses Etkinliği Algılama (VAD), modelin bir kişinin ne zaman konuştuğunu algılamasını sağlar. Bu özellik, modele istediğiniz zaman müdahale etmenize olanak tanıdığı için doğal sohbetler oluşturmak açısından çok önemlidir. VAD varsayılan olarak etkindir.
Kesintileri yönetme de dahil olmak üzere VAD'nin davranışını özelleştirebilirsiniz. Alternatif olarak, konuşma sıraları üzerinde tam manuel kontrol sağlamak için (ör. bas-konuş arayüzü için) otomatik VAD'yi devre dışı bırakabilirsiniz.
Ses Etkinliği Algılama'yı (VAD) yapılandırma
|
Bu sayfada sağlayıcıya özel içerikleri ve kodları görüntülemek için Gemini API sağlayıcınızı tıklayın. |
Aşağıdaki örnekte, model yapılandırmasının bir parçası olarak realtimeInputConfig ayarını yaparak VAD'nin davranışını nasıl özelleştirebileceğiniz gösterilmektedir.
Bu bölümün ilerleyen kısımlarındaki tabloda bu yapılandırma için kullanılabilen ayarlar hakkında bilgi edinebilirsiniz.
Swift
// ...
let liveModel = FirebaseAI.firebaseAI(backend: .googleAI()).liveModel(
modelName: "GEMINI_LIVE_API_MODEL_NAME",
generationConfig: LiveGenerationConfig(
responseModalities: [.audio],
// Configure voice activity detection (VAD), interruption handling, and turn coverage.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
realtimeInputConfig: RealtimeInputConfig(
automaticActivityDetection: ActivityDetectionConfig(
startSensitivity: .low,
endSensitivity: .low,
prefixPadding: .milliseconds(20),
silenceDuration: .milliseconds(500)
),
activityHandling: .interrupt,
turnCoverage: .onlyActivity
)
)
)
Kotlin
// ...
val liveModel = Firebase.ai(backend = GenerativeBackend.googleAI()).liveModel(
modelName = "GEMINI_LIVE_API_MODEL_NAME",
generationConfig = liveGenerationConfig {
responseModality = ResponseModality.AUDIO
// Configure voice activity detection (VAD), interruption handling, and turn coverage.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
realtimeInputConfig = realtimeInputConfig {
automaticActivityDetection = ActivityDetectionConfig.builder()
.setStartSensitivity(ActivityDetectionConfig.Sensitivity.LOW)
.setEndSensitivity(ActivityDetectionConfig.Sensitivity.LOW)
.setPrefixPaddingMs(20)
.setSilenceDurationMs(500)
.build()
activityHandling = RealtimeInputConfig.ActivityHandling.INTERRUPT
turnCoverage = RealtimeInputConfig.TurnCoverage.ONLY_ACTIVITY
}
}
)
Java
// ...
LiveGenerativeModel lm = FirebaseAI.getInstance(GenerativeBackend.googleAI()).liveModel(
"GEMINI_LIVE_API_MODEL_NAME",
new LiveGenerationConfig.Builder()
.setResponseModality(ResponseModality.AUDIO)
// Configure voice activity detection (VAD), interruption handling, and turn coverage.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
.setRealtimeInputConfig(RealtimeInputConfig.builder()
.setAutomaticActivityDetection(ActivityDetectionConfig.builder()
.setStartSensitivity(ActivityDetectionConfig.Sensitivity.LOW)
.setEndSensitivity(ActivityDetectionConfig.Sensitivity.LOW)
.setPrefixPaddingMs(20)
.setSilenceDurationMs(500)
.build())
.setActivityHandling(RealtimeInputConfig.ActivityHandling.INTERRUPT)
.setTurnCoverage(RealtimeInputConfig.TurnCoverage.ONLY_ACTIVITY)
.build())
.build()
);
Web
Not yet supported for Web apps - check back soon!
Dart
// ...
final _liveModel = FirebaseAI.googleAI().liveGenerativeModel(
model: 'GEMINI_LIVE_API_MODEL_NAME',
liveGenerationConfig: LiveGenerationConfig(
responseModalities: [ResponseModalities.audio],
// Configure voice activity detection (VAD), interruption handling, and turn coverage.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
realtimeInputConfig: RealtimeInputConfig(
automaticActivityDetection: ActivityDetectionConfig(
startSensitivity: Sensitivity.low,
endSensitivity: Sensitivity.low,
prefixPaddingMS: 20,
silenceDurationMS: 500,
),
activityHandling: ActivityHandling.interrupt,
turnCoverage: TurnCoverage.onlyActivity,
),
),
);
Unity
// ...
var liveModel = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetLiveModel(
modelName: "GEMINI_LIVE_API_MODEL_NAME",
liveGenerationConfig: new LiveGenerationConfig(
responseModalities: new[] { ResponseModality.Audio },
// Configure voice activity detection (VAD), interruption handling, and turn coverage.
// IMPORTANT: Example values shown here. Make sure to update for your use case.
realtimeInputConfig: new RealtimeInputConfig(
automaticActivityDetection: new ActivityDetectionConfig(
startSensitivity: ActivityDetectionConfig.Sensitivity.Low,
endSensitivity: ActivityDetectionConfig.Sensitivity.Low,
prefixPaddingMS: 20,
silenceDurationMS: 500
),
activityHandling: RealtimeInputConfig.ActivityHandling.Interrupt,
turnCoverage: RealtimeInputConfig.TurnCoverage.OnlyActivity
)
)
);
Kullanılabilir VAD yapılandırma ayarları
| Ayar | Desteklenen değerler | Açıklama |
|---|---|---|
Otomatik etkinlik algılama (automaticActivityDetection)
|
||
startSensitivity |
|
Sunucunun, kullanıcının ne zaman konuşmaya başladığını ne kadar kolay algılayacağını belirler:
|
endSensitivity |
|
Sunucunun, kullanıcının konuşmayı bıraktığını ne kadar kolay algılayacağını belirler:
|
prefixPadding |
Milisaniye cinsinden süre (varsayılan: Yok (0 ms)) |
Konuşma algılanmadan önce dahil edilecek ses miktarını tanımlar. Bu "geriye dönük" arabellek, modelin konuşmanın başlangıcını tam olarak yakalamasını sağlar. Buna, genellikle algılayıcı tetiklenmeden önce başlayan ilk hece de dahildir.
|
silenceDuration |
Milisaniye cinsinden süre (varsayılan: ~800 ms) |
Sunucunun, konuşma sırasını sonlandırmadan önce sessizlikte ne kadar bekleyeceğini tanımlar. Bu, sistemin cümle ortasındaki doğal duraklamalara (düşünme, nefes alma veya yan cümle sınırları gibi) ne kadar toleranslı olduğunu belirler.
|
Kesinti davranışı (activityHandling)
|
||
activityHandling |
|
Sunucunun, yanıt oluştururken gelen kullanıcı etkinliğini nasıl işleyeceğini tanımlar:
|
Dönüş bağlamı kapsamı (turnCoverage)
|
||
turnCoverage |
|
Sohbet sırası bağlamına hangi akış girişinin dahil edileceğini tanımlar:
|
Kesintileri yönetme
Model bir yanıt oluştururken sunucu gelen kullanıcı konuşmasını algılarsa ve activityHandling, INTERRUPT (varsayılan) olarak ayarlanmışsa aşağıdaki davranışlara dikkat edin:
Üretim iptal edilir: Model, yanıtını hemen durdurur ve bekleyen araç çağrılarını siler.
Oturum geçmişi kesilir: Yalnızca kesintiden önce uygulamanıza iletilen içerik, oturum bağlamı penceresinde korunur.
Kesinti sinyali gönderilir: Sunucu, oluşturma işleminin kesintiye uğradığını belirten bir yanıt mesajı gönderir (ör. Swift'te
wasInterruptedveya Kotlin, Java, Web, Flutter ve Unity'deinterrupted).
Otomatik Ses Etkinliği Algılama'yı (VAD) devre dışı bırakma
Sohbet sıraları üzerinde tam manuel kontrol sahibi olmak için (ör. bas-konuş arayüzü için) hassasiyet parametrelerini yapılandırmak yerine otomatik Ses Etkinliği Algılama'yı (VAD) devre dışı bırakabilirsiniz.
Otomatik algılama devre dışı bırakıldığında sunucu, konuşmayı otomatik olarak algılamaz veya ses sessizliğine göre yanıtları tetiklemez. Bunun yerine, uygulamanızın etkin oturum sırasında kullanıcı etkinliği sınırlarını manuel olarak bildirmesi gerekir.
1. Model yapılandırmasında otomatik VAD'yi devre dışı bırakma
|
Bu sayfada sağlayıcıya özel içerikleri ve kodları görüntülemek için Gemini API sağlayıcınızı tıklayın. |
Swift
// ...
let liveModel = FirebaseAI.firebaseAI(backend: .googleAI()).liveModel(
modelName: "GEMINI_LIVE_API_MODEL_NAME",
generationConfig: LiveGenerationConfig(
responseModalities: [.audio],
// Disable automatic voice activity detection (VAD).
realtimeInputConfig: RealtimeInputConfig(
automaticActivityDetection: .disabled()
)
)
)
Kotlin
// ...
val liveModel = Firebase.ai(backend = GenerativeBackend.googleAI()).liveModel(
modelName = "GEMINI_LIVE_API_MODEL_NAME",
generationConfig = liveGenerationConfig {
responseModality = ResponseModality.AUDIO
// Disable automatic voice activity detection (VAD).
realtimeInputConfig = realtimeInputConfig {
automaticActivityDetection = ActivityDetectionConfig.disabled()
}
}
)
Java
// ...
LiveGenerativeModel lm = FirebaseAI.getInstance(GenerativeBackend.googleAI()).liveModel(
"GEMINI_LIVE_API_MODEL_NAME",
new LiveGenerationConfig.Builder()
.setResponseModality(ResponseModality.AUDIO)
// Disable automatic voice activity detection (VAD).
.setRealtimeInputConfig(RealtimeInputConfig.builder()
.setAutomaticActivityDetection(ActivityDetectionConfig.disabled())
.build())
.build()
);
Web
Not yet supported for Web apps - check back soon!
Dart
// ...
final _liveModel = FirebaseAI.googleAI().liveGenerativeModel(
model: 'GEMINI_LIVE_API_MODEL_NAME',
liveGenerationConfig: LiveGenerationConfig(
responseModalities: [ResponseModalities.audio],
// Disable automatic voice activity detection (VAD).
realtimeInputConfig: RealtimeInputConfig(
automaticActivityDetection: ActivityDetectionConfig.disabled(),
),
),
);
Unity
// ...
var liveModel = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetLiveModel(
modelName: "GEMINI_LIVE_API_MODEL_NAME",
liveGenerationConfig: new LiveGenerationConfig(
responseModalities: new[] { ResponseModality.Audio },
// Disable automatic voice activity detection (VAD).
realtimeInputConfig: new RealtimeInputConfig(
automaticActivityDetection: ActivityDetectionConfig.Disabled()
)
)
);
2. Kullanıcı etkinliği sınırlarını manuel olarak bildirme
VAD'yi devre dışı bırakırsanız uygulamanızın her kullanıcı etkinliği sırasının sınırlarını manuel olarak belirlemesi gerekir:
Etkinlik başlangıcını bildirme: Ses verilerini göndermeden önce
sendStartActivityRealtimeyöntemini çağırın (örneğin, kullanıcı bas-konuş düğmesine bastığında).Kullanıcı girişini aktarma:
sendAudioRealtimekullanarak ses (veya video) verilerini sürekli olarak aktarın.Etkinlik sonunu bildirme: Kullanıcı konuşmayı bitirdiğinde (ör. kullanıcı bas-konuş düğmesini bıraktığında)
sendStopActivityRealtimeyöntemini çağırın. Bu, kullanıcının sırasının bittiğini gösterir ve modelin yanıtını tetikler.
Swift
// If you disable automatic voice activity detection (VAD), you need to manually demarcate user activity.
// Signal the start of user activity (for example, on push-to-talk button press).
await session.sendStartActivityRealtime()
// Stream user audio data while the user speaks.
await session.sendAudioRealtime(audioData)
// Signal the end of user activity (for example, on button release) to trigger model response.
await session.sendStopActivityRealtime()
Kotlin
// If you disable automatic voice activity detection (VAD), you need to manually demarcate user activity.
// Signal the start of user activity (for example, on push-to-talk button press).
session.sendStartActivityRealtime()
// Stream user audio data while the user speaks.
session.sendAudioRealtime(audioData)
// Signal the end of user activity (for example, on button release) to trigger model response.
session.sendStopActivityRealtime()
Java
// If you disable automatic voice activity detection (VAD), you need to manually demarcate user activity.
// Signal the start of user activity (for example, on push-to-talk button press).
session.sendStartActivityRealtime();
// Stream user audio data while the user speaks.
session.sendAudioRealtime(audioData);
// Signal the end of user activity (for example, on button release) to trigger model response.
session.sendStopActivityRealtime();
Web
Not yet supported for Web apps - check back soon!
Dart
// If you disable automatic voice activity detection (VAD), you need to manually demarcate user activity.
// Signal the start of user activity (for example, on push-to-talk button press).
await session.sendStartActivityRealtime();
// Stream user audio data while the user speaks.
await session.sendAudioRealtime(audioData);
// Signal the end of user activity (for example, on button release) to trigger model response.
await session.sendStopActivityRealtime();
Unity
// If you disable automatic voice activity detection (VAD), you need to manually demarcate user activity.
// Signal the start of user activity (for example, on push-to-talk button press).
await session.SendStartActivityRealtimeAsync();
// Stream user audio data while the user speaks.
await session.SendAudioRealtimeAsync(audio: audioData);
// Signal the end of user activity (for example, on button release) to trigger model response.
await session.SendStopActivityRealtimeAsync();
Oturum yönetimi
Oturumlarla ilgili aşağıdaki konular hakkında bilgi edinin:
Aşağıdakiler gibi gelişmiş özellikler:
Bağlantı ve oturum süresi sınırları, oturum bağlam penceresi sınırları ve sıklık sınırları dahil olmak üzere oturumla ilgili sınırlar.
Oturum sınırlarını yönetme seçenekleri: