-2

I have set up a flask application that records voice using python(sounddevice and pydub) libraries and converts it into text.

Application is running well on localhost but when I deployed the application on Amazon-ec2 instance it records blank file .

It doesn't show any error but it records nothing. Can anyone help how to solve this?

`

def record(self):
        time.sleep(2)
        samplerate = 8000  
        duration = 5 # seconds
        filename = path+'yes.wav'
        print("start")
        mydata = sd.rec(int(samplerate * duration), samplerate=samplerate,channels=1, blocking=True)
        print("end")
        print(type(mydata))
        sd.wait()
        sf.write(filename, mydata, samplerate)`

1 Answers1

0

EC2s are virtual servers, not physical machines.

It is unlikely you would be able to record any meaningful data from audio inputs on an EC2 - your program is almost certainly waiting for input from the audio device but not receiving any, hence the empty file.

mcfinnigan
  • 11,442
  • 35
  • 28
  • I want to record audio from audio inputs on my host and not from ec2, that is my browser should open a microphone and start recording. Can you suggest something for that? – Akash Rajpuria Feb 25 '20 at 11:16
  • @AkashRajpuria yes, write a web application that runs on EC2 and that offers a web page to the user that includes an audio recording component. – jarmod Feb 25 '20 at 13:18
  • @jarmod I did the same, created a web app using flask and it offers audio recording but when the button is clicked it records nothing as I explained. – Akash Rajpuria Feb 25 '20 at 13:31
  • Where is the microphone? It's on the user's laptop. It's not on the EC2 instance. The recording cannot happen on the server in your Flask app. It has to happen on the client, in the browser. – jarmod Feb 25 '20 at 13:44