Menu

How to suppress microphone during voice playback using pocketsphinx/festival

Help
Ross Munro
2021-04-25
2021-04-25
  • Ross Munro

    Ross Munro - 2021-04-25

    I'm playing with a simple voice assistant model using pocketsphinx and festival. Livespeech listens through the mic and then festival.sayText() plays the phrase back through the speakers. This sets up a charming but useless feedback loop whereby pocketsphinx repeatedly attempts to decipher it's own utterances being picked up through the mic (I assume). I need to suppress the microphone before the festival.sayText() function plays, then restore it after. How do you do that.

    import os
    from pocketsphinx import LiveSpeech
    import festival
    import speech_recognition as sr
    
    model_path = '/data/python/Eliza'
    print(model_path)
    
    speech = LiveSpeech(
        verbose=False,
        sampling_rate=16000,
        buffer_size=2048,
        no_search=False,
        full_utt=False,
        hmm=os.path.join(model_path, 'en-us-mm'),
        lm=os.path.join(model_path, 'en-us.lm.bin'),
        dic=os.path.join(model_path, 'cmudict-en-us.dict')
    )
    
    for phrase in speech:
        festival.sayText(str(phrase))
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.