On-Device Speech-to-Text

개요

Speech-to-Text On Device는 내장형 기기에서 서버 품질의 음성 기술을 지원합니다. 이렇게 하면 네트워크 또는 Google 서버에 연결하지 않고 완전히 기기 내에서 스트리밍 음성 인식을 실행할 수 있습니다.

이 솔루션은 양방향 스트리밍 gRPC 서버입니다. 이 서버는 Cloud Speech 양방향 스트리밍 API와 비슷하게 오디오를 사용해서 실시간으로 이벤트를 내보냅니다.

아래 API는 불완전한 샘플입니다.

service SpeechToText {
  rpc StreamingRecognize(stream StreamingRecognizeRequest)
      returns (stream StreamingRecognizeResponse) {}
}

message StreamingRecognizeRequest {
  oneof streaming_request {
    StreamingRecognitionConfig streaming_config = 1;
    bytes audio_content = 2;
  }
  // ...
}

message StreamingRecognizeResponse {
  enum SpeechEventType {
    // ...

    // This event indicates that the server has detected the beginning of human
    // voice activity in the stream. This event can be returned multiple times
    // if speech starts and stops repeatedly throughout the stream.
    START_OF_SPEECH = 2;

    // This event indicates that the server has detected the end of human voice
    // activity in the stream. This event can be returned multiple times if
    // speech starts and stops repeatedly throughout the stream.
    END_OF_SPEECH = 3;
  }
  // ...
  repeated StreamingRecognitionResult results = 2;
  // ...

  SpeechEventType speech_event_type = 4;
}

빠른 시작 예시

다음은 기기 내 서버를 사용하는 예시입니다.

  1. 언어 팩(LP)을 선택하고 인식 서버를 시작합니다.

    언어 팩은 모델 및 구성이 포함된 디렉터리입니다. Speech to Text 서버는 한 번에 하나의 언어 팩을 지원합니다.

      ./speech_to_text_server --server_ip="0.0.0.0" --port=8000 \
         --language_pack=/../en_us
    
  2. 명령줄 클라이언트를 사용하여 오디오 파일(WAV)로 서버 시도

      ./speech_to_text_client --server_ip="0.0.0.0" --port=8000 \
        --audio=/../hello.wav
    

    명령줄 클라이언트 옵션 보기

      ./speech_to_text_client --help