# How to get the microphone streaming input file when using blocks?

**URL:** <https://discuss.huggingface.co/t/how-to-get-the-microphone-streaming-input-file-when-using-blocks/37204>\
**Category:** 🔒 Gradio\
**Created:** [April 20, 2023, 10:10am UTC](https://discuss.huggingface.co/t/how-to-get-the-microphone-streaming-input-file-when-using-blocks/37204 "2023-04-20T10:10:45Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![radames](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/radames/32/28246_2.png) [@radames](https://discuss.huggingface.co/u/radames)\
**Post date:** [April 21, 2023, 10:00pm UTC](https://discuss.huggingface.co/t/how-to-get-the-microphone-streaming-input-file-when-using-blocks/37204/2 "2023-04-21T22:00:22Z")

</div>

this responds to your question

> [@Can we set blocks with live (like interface)?](https://discuss.huggingface.co/t/can-we-set-blocks-with-live-like-interface/37329/2):
>
> hi @laro1 here is an example using a Camera, but you can replace with the Audio import gradio as gr import numpy as np def flip(im): return np.flipud(im) with gr.Blocks() as demo: with gr.Row(): with gr.Column(): camera = gr.Image(source="webcam") with gr.Column(): image = gr.Image() camera.stream(fn=flip, inputs=[camera], outputs=[image]) demo.launch()

```python

import gradio as gr
from transformers import pipeline
import time

pipe = pipeline("automatic-speech-recognition")

def transcribe(audio, state=""):
    print(audio)
    time.sleep(2)
    text = pipe(audio)["text"]
    state += text + " "
    return state, state

with gr.Blocks() as demo:
  state = gr.State(value="")
  with gr.Row():
      with gr.Column():
        audio = gr.Audio(source="microphone", type="filepath") 
      with gr.Column():
        textbox = gr.Textbox()
  audio.stream(fn=transcribe, inputs=[audio, state], outputs=[textbox, state])

demo.launch(debug=True)

```

---

_[View the full topic](https://discuss.huggingface.co/t/how-to-get-the-microphone-streaming-input-file-when-using-blocks/37204)._
