2016-10-26 8 views
0

Google Cloud Speech API를 통해 실시간 음성 인식이 필요합니다. 그러나 그것은 여전히 ​​베타 버전이며 많은 유용한 것들이 인터넷에 없습니다.Google Cloud Streaming Speech API

여기에 샘플이 거의 없지만 C#으로 API 스트리밍이 표시되지 않는다면 Google 오디오 입력 인 Google Cloud Speech API를 스팀으로 사용할 수 없다는 것을 의미합니까?

누구나 .NET을 사용하여 Cloud Speech API에 스트리밍 오디오 입력을 시도 했습니까?

참고로 정상적인 Google의 웹 스피치 API를 사용할 수 없습니다. Goolge Cloud Speech API 만 사용해야합니다.

+0

는 C#으로 그것을 만든 사람이 될 것 같다 :

그런 다음 콘텐츠를 스트리밍해야합니다. 그러나 샘플 코드가 없습니다. https://groups.google.com/forum/#!topic/cloud-speech-discuss/cdGB40GAeOc 무엇이든 찾으면 알려주세요. 나는 그 해답을 찾고 있었다. – Hespen

+1

Hespen, 임시 해결책으로 node.js 바이너리 서버를 소개하고 오디오 스트리밍을 위해 websocket을 통해 JS에 연결했습니다. 그런 다음 Node.js는 Google Cloud Speech API와 통신합니다. 이 솔루션은 현재 잘 작동하고있는 것 같지만 실제로 C#을 사용하여 간단하고 깨끗하게 만들 수 있습니다. –

+0

정보 주셔서 감사합니다! – Hespen

답변

2

당신은 여기에서 샘플 응용 프로그램을 다운로드해야합니다 : 퀵 스타트 및 인식 : https://cloud.google.com/speech/docs/samples

당신은 음성 샘플을 찾을 수 있습니다.

Recogize에는 많은 옵션이 있으며 그 중 하나는 Listen입니다. 이 샘플은 오디오를 스트리밍하고 콘솔에 결과를 지속적으로 기록합니다.

이 샘플에서는 스트리밍에 protobuf 바이트 스트림을 사용합니다.

var credential = GoogleCredential.FromFile("privatekey.json").CreateScoped(SpeechClient.DefaultScopes); 
var channel = new Grpc.Core.Channel(SpeechClient.DefaultEndpoint.ToString(), credential.ToChannelCredentials()); 
var speech = SpeechClient.Create(channel); 
var streamingCall = speech.StreamingRecognize(); 
// Write the initial request with the config. 
await streamingCall.WriteAsync(
    new StreamingRecognizeRequest() 
    { 
     StreamingConfig = new StreamingRecognitionConfig() 
     { 
      Config = new RecognitionConfig() 
      { 
       Encoding = 
       RecognitionConfig.Types.AudioEncoding.Linear16, 
       SampleRateHertz = 16000, 
       LanguageCode = "hu", 
      }, 
      InterimResults = true, 
     } 
    }); 

언어를 변경해야 물론 : 다음은 코드의 주요 부분이다.

streamingCall.WriteAsync(
    new StreamingRecognizeRequest() 
    { 
     AudioContent = Google.Protobuf.ByteString 
      .CopyFrom(args.Buffer, 0, args.BytesRecorded) 
    }).Wait();