Live API의 구성 옵션


Live API의 기본 구현만으로도 사용자를 위한 매력적이고 강력한 상호작용을 빌드할 수 있습니다. 다음 구성 옵션을 사용하여 환경을 더 맞춤설정할 수 있습니다.



대답 음성 및 언어

모델이 특정 음성으로 대답하도록 하고 모델이 다른 언어로 대답하도록 영향을 줄 수 있습니다.

대답 음성 지정

Gemini API 제공업체를 클릭하여 이 페이지에서 제공업체별 콘텐츠와 코드를 확인합니다.

Live API는 각각 고유한 특성을 가진 30가지 합성 HD 음성을 지원합니다. 아래 섹션을 펼치면 대답 음성 옵션 목록을 확인하고 각 음성의 데모를 들을 수 있습니다.

응답 음성을 지정하지 않으면 기본값은 Puck입니다.

대답 음성을 지정하려면 모델 구성의 일부로 speechConfig 객체 내에서 음성 이름을 설정합니다.

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")
    )
);

// ...

대답 언어에 영향을 미칩니다.

Live API 모델은 대답에 적합한 언어를 자동으로 선택합니다.

모델이 영어 이외의 언어로 응답하거나 항상 특정 언어로 응답하도록 하려면 다음 예시와 같이 시스템 안내를 사용하여 모델의 응답에 영향을 줄 수 있습니다.

  • 영어가 아닌 언어가 적절할 수 있음을 모델에 강조

    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.
    



오디오 입력 및 출력 스크립트 작성

Gemini API 제공업체를 클릭하여 이 페이지에서 제공업체별 콘텐츠와 코드를 확인합니다.

모델 응답의 일부로 오디오 입력 및 모델의 오디오 응답 스크립트를 수신할 수 있습니다. 이 구성은 모델 구성의 일부로 설정합니다.

  • 오디오 입력의 스크립트 작성을 위해 inputAudioTranscription를 추가합니다.

  • 모델의 오디오 응답 스크립트 작성의 경우 outputAudioTranscription를 추가합니다.

다음에 유의하세요.

  • 다음 예시와 같이 입력 및 출력의 스크립트를 모두 반환하도록 모델을 구성하거나 둘 중 하나만 반환하도록 구성할 수 있습니다.

  • 스크립트는 오디오와 함께 스트리밍되므로 각 차례에서 텍스트 부분과 마찬가지로 수집하는 것이 가장 좋습니다.

  • 스크립트 작성 언어는 오디오 입력과 모델의 오디오 응답에서 추론됩니다.

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
}

// ...



음성 활동 감지(VAD)

음성 활동 감지 (VAD)를 사용하면 모델이 사람이 말하는 시점을 인식할 수 있습니다. 언제든지 모델을 중단할 수 있어 이는 자연스러운 대화를 만드는 데 필수적입니다. VAD는 기본적으로 사용 설정되어 있습니다.

중단 처리를 포함하여 VAD 동작을 맞춤설정할 수 있습니다. 또는 자동 VAD를 사용 중지하여 대화 차례를 완전히 수동으로 제어할 수 있습니다 (예: 푸시 투 토크 인터페이스).

음성 활동 감지 (VAD) 구성

Gemini API 제공업체를 클릭하여 이 페이지에서 제공업체별 콘텐츠와 코드를 확인합니다.

다음 예시에서는 모델 구성의 일부로 realtimeInputConfig를 설정하여 VAD의 동작을 맞춤설정하는 방법을 보여줍니다. 이 섹션 뒷부분의 표에서 이 구성에 사용할 수 있는 설정에 대해 알아보세요.

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
        )
    )
);

사용 가능한 VAD 구성 설정

설정 지원되는 값 설명
자동 활동 감지 (automaticActivityDetection)
startSensitivity
  • LOW(기본)
  • HIGH

사용자가 말하기 시작할 때 서버가 얼마나 쉽게 감지하는지 결정합니다.

  • LOW: 희미한 소리에 덜 민감합니다. 이렇게 하면 주변 소음으로 인해 실수로 발화 차례가 시작되는 것을 방지할 수 있습니다.
  • HIGH: 더 민감함 이렇게 하면 작은 소리나 부드러운 음성을 빠르게 감지할 수 있습니다.
endSensitivity
  • LOW(기본)
  • HIGH

사용자가 말하기를 중지할 때 서버가 얼마나 쉽게 감지하는지 결정합니다.

  • LOW: 후행 일시중지에 덜 민감합니다. 서버는 문장 끝에서 자연스러운 망설임이나 더 조용한 단어를 수용합니다.
  • HIGH: 더 민감함 음성 수준이 떨어지면 서버가 즉시 발화 차례를 종료합니다.
prefixPadding 밀리초 단위의 기간
(기본값: 없음 (0ms))

음성이 감지되기 전에 포함할 오디오의 양을 정의합니다.

이 '되돌아보기' 버퍼는 모델이 감지기가 트리거되기 전에 시작되는 첫 음절을 포함하여 음성의 전체 시작을 캡처하도록 합니다.

  • 0의 기본값으로 인해 단어의 시작 부분이 잘릴 수 있습니다.
  • 권장: 20~50밀리초
silenceDuration 밀리초 단위의 기간
(기본값: ~800ms)

발화 차례를 종료하기 전에 서버가 침묵을 통해 대기하는 시간을 정의합니다. 이는 시스템이 자연스러운 문장 중간 일시중지 (예: 생각, 호흡, 절 경계)를 얼마나 허용하는지를 결정합니다.

  • 권장 (500~800ms): 적절한 균형을 제공합니다. 모델은 문맥이 풍부한 완전한 오디오를 수신하면서도 응답 지연 시간을 합리적으로 유지합니다.
  • 너무 낮음 (200ms 미만): 자연스러운 일시중지 중에 발화 차례를 종료하여 발화를 작은 조각으로 분할하므로 스크립트 작성 및 응답 품질이 저하될 수 있습니다.
  • 너무 높음 (2,000ms 초과): 모델이 응답을 시작하기 전에 눈에 띄는 지연이 추가됩니다.
중단 동작 (activityHandling)
activityHandling
  • INTERRUPT(기본)
  • NO_INTERRUPT

응답을 생성하는 동안 서버가 수신되는 사용자 활동을 처리하는 방법을 정의합니다.

  • INTERRUPT: 사용자 활동이 감지되면 모델의 현재 대답을 즉시 취소합니다.
  • NO_INTERRUPT: 중단 없이 응답을 계속 생성합니다.
대화 컨텍스트 범위 (turnCoverage)
turnCoverage
  • ONLY_ACTIVITY(기본)
  • ALL_INPUT
  • AUDIO_ACTIVITY_AND_ALL_VIDEO

대화 차례 컨텍스트에 포함되는 스트리밍 입력을 정의합니다.

  • ONLY_ACTIVITY: 무음 구간을 제외하고 사용자 활동이 감지된 세그먼트만 유지합니다.
  • ALL_INPUT: 오디오 무음을 포함하여 스트리밍된 모든 입력을 유지합니다.
  • AUDIO_ACTIVITY_AND_ALL_VIDEO: 스트리밍된 모든 동영상 프레임을 유지하지만 활동이 감지된 오디오 세그먼트만 유지합니다.

중단 처리

모델이 대답을 생성하는 동안 서버가 수신 사용자 음성을 감지하고 activityHandling가 INTERRUPT (기본값)로 설정된 경우 다음 동작에 유의하세요.

  • 생성이 취소됨: 모델이 즉시 대답을 중지하고 대기 중인 도구 호출을 삭제합니다.

  • 세션 기록이 잘림: 중단되기 전에 이미 앱으로 전송된 콘텐츠만 세션 컨텍스트 창에 보존됩니다.

  • 중단 신호가 전송됨: 서버가 생성이 중단되었음을 나타내는 응답 메시지를 전송합니다 (예: Swift의 wasInterrupted 또는 Kotlin, Java, 웹, Flutter, Unity의 interrupted).

자동 음성 활동 감지 (VAD) 사용 중지

대화 차례를 완전히 수동으로 제어하려면 (예: 푸시 투 토크 인터페이스의 경우) 민감도 매개변수를 구성하는 대신 자동 음성 활동 감지(VAD)를 사용 중지하면 됩니다.

자동 감지가 사용 중지되면 서버는 오디오 무음 상태를 기반으로 음성을 자동으로 감지하거나 응답을 트리거하지 않습니다. 대신 앱은 활성 세션 중에 사용자 활동 경계를 수동으로 알려야 합니다.

1. 모델 구성에서 자동 VAD 사용 중지

Gemini API 제공업체를 클릭하여 이 페이지에서 제공업체별 콘텐츠와 코드를 확인합니다.

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. 사용자 활동 경계를 수동으로 알림

VAD를 사용 중지하는 경우 앱에서 각 사용자 활동 차례의 경계를 수동으로 구분해야 합니다.

  1. 활동 시작 신호: 오디오 데이터를 전송하기 전에 sendStartActivityRealtime를 호출합니다 (예: 사용자가 푸시 투 토크 버튼을 누를 때).

  2. 사용자 입력 스트리밍: sendAudioRealtime를 사용하여 오디오 (또는 동영상) 데이터를 지속적으로 스트리밍합니다.

  3. 활동 종료 신호: 사용자가 말하기를 마치면 (예: 사용자가 푸시 투 토크 버튼을 놓을 때) sendStopActivityRealtime를 호출합니다. 이는 사용자 차례의 종료를 알리고 모델의 대답을 트리거합니다.

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();



세션 관리

다음 세션 관련 주제에 대해 알아보세요.