# Use wav2vec2 models with a microphone easily

**URL:** <https://discuss.huggingface.co/t/use-wav2vec2-models-with-a-microphone-easily/5522>\
**Category:** Beginners\
**Created:** [April 15, 2021, 11:44am UTC](https://discuss.huggingface.co/t/use-wav2vec2-models-with-a-microphone-easily/5522 "2021-04-15T11:44:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliverguhr](https://avatars.discourse-cdn.com/v4/letter/o/b487fb/32.png) [@oliverguhr](https://discuss.huggingface.co/u/oliverguhr)\
**Post date:** [April 15, 2021, 11:44am UTC](https://discuss.huggingface.co/t/use-wav2vec2-models-with-a-microphone-easily/5522/1 "2021-04-15T11:44:46Z")

</div>

Hello folks,  
I wrote a little lib to be able to use any wav2vec2 model from the model hub with a microphone. Since wav2vec2 does not support streaming mode, I used voice activity detection to create audio chunks that I can feed into the model.

Here is a little example, you can [find the code on github](https://github.com/oliverguhr/wav2vec2-live).

```
from live_asr import LiveWav2Vec2

german_model = "maxidl/wav2vec2-large-xlsr-german"
asr = LiveWav2Vec2(german_model,device_name="default")
asr.start()

try:        
    while True:
        text,sample_length,inference_time = asr.get_last_text()                        
        print(f"{sample_length:.3f}s"
        +f"\t{inference_time:.3f}s"
        +f"\t{text}")
        
except KeyboardInterrupt:   
    asr.stop() 

```

If you have any questions or feedback feel free to write me.

---

<div class="post-metadata">

**Author:** ![SamuelAzran](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@SamuelAzran](https://discuss.huggingface.co/u/SamuelAzran)\
**Post date:** [May 20, 2021, 10:26pm UTC](https://discuss.huggingface.co/t/use-wav2vec2-models-with-a-microphone-easily/5522/2 "2021-05-20T22:26:21Z")

</div>

Pretty cool! would you consider making an implementation for Google Colab / notebooks? Similar to this:

> <https://github.com/voidful/huggingface_notebook/blob/main/xlsr_gpt.ipynb>

But with the VAD to get a near real-time transcription.

---

<div class="post-metadata">

**Author:** ![oliverguhr](https://avatars.discourse-cdn.com/v4/letter/o/b487fb/32.png) [@oliverguhr](https://discuss.huggingface.co/u/oliverguhr)\
**Post date:** [May 28, 2021, 3:14pm UTC](https://discuss.huggingface.co/t/use-wav2vec2-models-with-a-microphone-easily/5522/3 "2021-05-28T15:14:43Z")

</div>

Since it runs pretty well on a CPU there is no need (at least for me) to run it on Colab.
