Google Speech-to-Text V2 chirp_3的流式传输从不返回中间结果(isFinal=false)
我在使用Google Cloud Speech-to-Text V2流式识别,使用chirp_3模型,通过gRPC。
我启用了中间结果,但我只收到最终结果( isFinal=true )。我从未收到任何中间结果( isFinal=false )。
我的流式配置本质上是:
StreamingRecognitionConfig streamingConfig =
StreamingRecognitionConfig.newBuilder()
.setConfig(
RecognitionConfig.newBuilder()
.addLanguageCodes(languageCode)
.setModel("chirp_3")
.setAutoDecodingConfig(AutoDetectDecodingConfig.newBuilder().build())
.setFeatures(
RecognitionFeatures.newBuilder()
.setEnableAutomaticPunctuation(true)
.build())
.build())
.setStreamingFeatures(
StreamingRecognitionFeatures.newBuilder()
.setInterimResults(true)
.build())
.build();
我测试了以下内容:
-
cmn-Hans-CN
-
en-US
-
WEBM_OPUS
-
LINEAR16
以下是处理返回结果的代码:
private void consumeV2Responses(RuntimeSession runtimeSession) {
for (com.google.cloud.speech.v2.StreamingRecognizeResponse response : runtimeSession.getV2Stream()) {
for (com.google.cloud.speech.v2.StreamingRecognitionResult result : response.getResultsList()) {
if (result.getAlternativesCount() == 0) {
continue;
}
com.google.cloud.speech.v2.SpeechRecognitionAlternative alternative = result.getAlternatives(0);
logRecognizeResult(runtimeSession, result.getIsFinal(), alternative.getTranscript(),
resolveConfidence(alternative.getConfidence(), result.getIsFinal()));
if (!StringUtils.hasText(alternative.getTranscript())) {
continue;
}
sendTranscriptResult(runtimeSession, alternative.getTranscript(),
resolveConfidence(alternative.getConfidence(), result.getIsFinal()),
result.getIsFinal());
}
}
}
private void logRecognizeResult(RuntimeSession runtimeSession, boolean finalResult, String transcript, Float confidence) {
log.info("[recognizeResult][sessionId({}) meetingId({}) provider({}) final({}) transcriptLength({}) confidence({}) transcript({})]",
runtimeSession.getSessionId(), runtimeSession.getMeetingId(), runtimeSession.getProvider(),
finalResult, transcript != null ? transcript.length() : 0, confidence, abbreviateTranscript(transcript));
}
在所有情况下,我的服务器日志只显示最终结果。例如:
[recognizeResult][sessionId(...)] provider(v2_chirp3) final(true) transcript(Hello everyone, my name is Nick.)
我从未看到任何final(false) / isFinal=false的结果。
我也确认了:
-
我确实在使用V2 StreamingRecognize
-
interimResults=true实际上已发送
-
我的服务器在记录日志之前没有过滤部分结果
-
我同时测试了WEBM_OPUS和原始LINEAR16
那么我的问题是:
-
chirp_3实际上在实践中会发出中间结果吗?
-
还是说,V2的 chirp_3即使interim_results=true,可能也只返回最终结果?
如果有人有V2 chirp_3返回isFinal=false的确切示例,那将非常有帮助。
解决方案
我的直觉是这可能是一个API/模型的限制,而不是代码错误。这个模型如此先进,以至于它在何时给出结果上有一种模式——而这种模式可能迫使它等待完全确定。
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。