Speech-to-Text no dispositivo

Visão geral

A Speech-to-Text OnDevice oferece tecnologia de fala com qualidade de servidor para dispositivos incorporados. Esse recurso permite executar reconhecimento de fala em streaming por completo no dispositivo, sem qualquer conexão com uma rede ou servidores do Google.

A solução é um servidor gRPC de streaming bidirecional. O servidor consome áudio e emite eventos em tempo real, semelhante à API de streaming bidirecional do Cloud Speech.

A API abaixo é um exemplo incompleto.

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

Exemplo de início rápido

Veja a seguir um exemplo de uso do servidor no dispositivo.

  1. Escolha um pacote de idiomas (LP) e inicie o servidor de reconhecimento.

    Um pacote de idiomas é um diretório que contém modelos e configurações. O servidor Speech-to-Text veiculará um pacote de idioma por vez.

      ./speech_to_text_server --server_ip="0.0.0.0" --port=8000 \
         --language_pack=/../en_us
    
  2. Usar o cliente de linha de comando para testar o servidor com um arquivo de áudio (WAV)

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

    Veja as opções de cliente de linha de comando com

      ./speech_to_text_client --help