당신은 여기에서 샘플 응용 프로그램을 다운로드해야합니다 : 퀵 스타트 및 인식 : 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();
는 C#으로 그것을 만든 사람이 될 것 같다 :
그런 다음 콘텐츠를 스트리밍해야합니다. 그러나 샘플 코드가 없습니다. https://groups.google.com/forum/#!topic/cloud-speech-discuss/cdGB40GAeOc 무엇이든 찾으면 알려주세요. 나는 그 해답을 찾고 있었다. – Hespen
Hespen, 임시 해결책으로 node.js 바이너리 서버를 소개하고 오디오 스트리밍을 위해 websocket을 통해 JS에 연결했습니다. 그런 다음 Node.js는 Google Cloud Speech API와 통신합니다. 이 솔루션은 현재 잘 작동하고있는 것 같지만 실제로 C#을 사용하여 간단하고 깨끗하게 만들 수 있습니다. –
정보 주셔서 감사합니다! – Hespen