2

I want to transmit real time voice signal recorded by usb MIC through uart using Raspberry pi 3b. But by using USB MIC it is not possible for me to transmit voice to uart directly without storing it. Please tell me how can i directly take the voice data and transmit it through uart.

The code I am using is:

 #!/usr/bin/python
 import os
 import serial
 ser=serial.Serial('/dev/ttyS0',19200)
 os.system("mkfifo audio1.fifo")

 with open("audio1.fifo") as fifo:
     audio1.fifo=ser.readline()
2

Here is what comes to mind first, but maybe there are other ways. Using FIFO file, arecord tool and using python here, something like this must be possible. :

enter image description here

  • 1
    Thank you sir . – kunal Jan 5 at 13:51
  • Thank you sir. Your suggestion saved my project and it is working really well. I have one more question that if i want to receive this transmitted audio by a raspberry pi and play it at the same time ,What should be my approach?? Can i do in this way ? create audio.fifo file->read uart in that fifo file->then open fifo file ->play the file. – kunal Jan 5 at 14:02
  • @kunal, Yes absolutely you can without problem. Read UARTWrite the buffer into fifo fileaplay /tmp/your.fifo (but you may need to adjust the sample rate and other audio parameters.) – Ephemeral Jan 5 at 19:31
  • Hello sir,i hope ur doing well, I'm facing a problem ,this is my code for receiving data, import os,import serial,ser=serial.Serial('/dev/ttyS0',19200),os.system("mkfifo audio1.fifo"),with open("audio1.fifo") as fifo:,audio1.fifo=ser.readline(). But it only creating audio1.fifo file but data is not written it fifo file.So can u plz suggest some correction . – kunal Jan 7 at 12:22
  • 1
    I am really sorry .I was confuse about the name that's why I said sir. – kunal Jan 7 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.