Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

192
Visualizações
How to make hotword detection service in android

I want to create a service that should listens for hotword in background such that when i say hello it should invoke an activity, how can i do this, about voiceInteractionService but I have read that Its not available to use, is it true? could anyone tell me the way i should solve this problem? Its about hotword detector

I have been following this

Tried this:

public class InteractionService extends VoiceInteractionService {

static final String TAG = "InteractionService" ;
private AlwaysOnHotwordDetector mHotwordDetector;

@Override
public void onCreate() {
    super.onCreate();

    Log.i(TAG, "service started");
}

@Override
public void onReady() {
    super.onReady();
    Log.i(TAG, "Creating " + this);

    mHotwordDetector = createAlwaysOnHotwordDetector("Hello"
,  Locale.forLanguageTag("en-US"), mHotwordCallback);
    Log.i(TAG, "onReady");
}

private final AlwaysOnHotwordDetector.Callback mHotwordCallback = 
new AlwaysOnHotwordDetector.Callback() {
           @Override
           public void onAvailabilityChanged(int status) {
                    Log.i(TAG, "onAvailabilityChanged(" + status + ")");
                    hotwordAvailabilityChangeHelper(status);
                }

                    @Override
            public void onDetected(AlwaysOnHotwordDetector
               .EventPayload eventPayload) {
                    Log.i(TAG, "onDetected");
                }

                    @Override
            public void onError() {
                    Log.i(TAG, "onError");
                }

                    @Override
            public void onRecognitionPaused() {
                    Log.i(TAG, "onRecognitionPaused");
                }

                    @Override
            public void onRecognitionResumed() {
                    Log.i(TAG, "onRecognitionResumed");
                }
        };

private void hotwordAvailabilityChangeHelper(int status) {

    Log.i(TAG, "Hotword availability = " + status);
    switch (status) {
        case AlwaysOnHotwordDetector.STATE_HARDWARE_UNAVAILABLE:
            Log.i(TAG, "STATE_HARDWARE_UNAVAILABLE");
            break;
        case AlwaysOnHotwordDetector.STATE_KEYPHRASE_UNSUPPORTED:
            Log.i(TAG, "STATE_KEYPHRASE_UNSUPPORTED");
            break;
        case AlwaysOnHotwordDetector.STATE_KEYPHRASE_UNENROLLED:
            Log.i(TAG, "STATE_KEYPHRASE_UNENROLLED");
            Intent enroll = mHotwordDetector.createEnrollIntent();
            Log.i(TAG, "Need to enroll with " + enroll);
            break;
        case AlwaysOnHotwordDetector.STATE_KEYPHRASE_ENROLLED:
            Log.i(TAG, "STATE_KEYPHRASE_ENROLLED - starting recognition");
            if (mHotwordDetector.startRecognition(0)) {
                Log.i(TAG, "startRecognition succeeded");
            } else {
                Log.i(TAG, "startRecognition failed");
            }
            break;
    }

    //    final static AlwaysOnHotwordDetector.Callback
}}
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Porcupine's service demo does exactly this.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda