Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio Not Transmitting from Raspberry Pi to Browser in Webrtc Bot #16

Closed
kadharsh opened this issue Nov 14, 2023 · 7 comments
Closed

Audio Not Transmitting from Raspberry Pi to Browser in Webrtc Bot #16

kadharsh opened this issue Nov 14, 2023 · 7 comments

Comments

@kadharsh
Copy link

kadharsh commented Nov 14, 2023

Thank you for this great project.

I've been working on setting up a Webrtc bot following the provided instructions. The project works wonderfully overall. However, I've encountered an issue with audio transmission from the Raspberry Pi to the browser.
I can successfully talk on my PC, and the Raspberry Pi is playing the sound. However, the audio is not transmitted from the Raspberry Pi to the browser. The camera and controls work as expected.

I've tested the audio recording on the Raspberry Pi using the arecord command, and it works fine. I can record and playback without any issues. I have also tried the gen2brain/malgo example code capture which was also working fine.

.env file:

srv_url = "wss://api.roboportal.io:8001"

public_key = "xxxxxx-xxxxxxxxx-xxxxxxxxx-xxxxxx"
secret_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

stun_urls = "stun:stun.l.google.com:19302"
video_codec_bit_rate = 1000000
frame_format = "RGBA"
video_width = 800
video_frame_rate = 30

audio_input_enabled = true
audio_output_enabled = true

output_mode = console
port_name = "/dev/serial/by-id/..."
baud_rate = 115200

bot_box_ipc_port = 5555
robot_ipc_port = 5556
robot_ipc_host = 127.0.0.1

camera_multiplexor_i2c_bus = 1

debug = true

I am using a generic USB audio card for capturing and playing the audio, which I have set as the default card in /usr/share/alsa/alsa.conf

My setup:

  • Raspberry Pi 4B
  • OS: 32bit Raspbian GNU/Linux 12 (bookworm)
  • go version 1.21.4

Let me know if you need more details. Appreciate your help!

@malykhin
Copy link
Member

Thanks for reporting this, @kadharsh.

We'll need a few days to ensure there is no regression and that the software is functioning correctly. We'll get back to you after confirming.

@kadharsh
Copy link
Author

Hi @malykhin

Thanks a ton for the quick response! Take your time, and I appreciate your efforts. Feel free to reach out if you need any more info or testing on my end.

@kadharsh kadharsh reopened this Nov 15, 2023
@malykhin
Copy link
Member

Hi @kadharsh
I've checked the microphone and it works well.
The mic that I tested (it's just the one that I was able to get quickly).
Steps I used to set it up:

  1. Getting the record device details:
Screenshot 2023-11-17 at 7 15 02 PM 2. Configuration: Screenshot 2023-11-17 at 7 15 23 PM 3. Setting the gain: Screenshot 2023-11-17 at 7 13 35 PM

@kadharsh
Copy link
Author

Hi @malykhin

I've reviewed my setup, and I seem to be following similar steps, but unfortunately, the audio is not coming through on the other side. Am I missing something?
Here is the configuration I'm using:
1 .env file is the same
2. record device details and OS:
Screenshot from 2023-11-20 11-22-38
3. Alsa Configuration
Screenshot from 2023-11-20 11-54-36
4. alsamixer
Screenshot from 2023-11-20 11-22-04
5. pion debug log
Screenshot from 2023-11-20 11-35-21

But no audio output from the browser, the speaker option in the video player is blacked out.
Screenshot from 2023-11-20 11-38-32

I've tested the microphone by recording a small audio file using this command arecord -f S16_LE -r 44100 audio_file.wav, and that's working.

@malykhin
Copy link
Member

The setup looks good to me.
Could you please try using headphones instead of speakers on your computer? I've noticed that my browser disables WebRTC audio if feedback occurs.
Could you please share the link to the audio device you're using? I can test it on my end.

@kadharsh
Copy link
Author

I tried using headphones with my PC, but unfortunately, the issue persists. The USB device I am using is Plextone GS3. Additionally, I attempted to use the microphone of the USB webcam Logitech C270, and the problem remained the same.

@kadharsh
Copy link
Author

I've identified the issue – it was related to ALSA. After installing pulseaudio, the miniaudio started selecting it as the backend, resolving the problem. Now, the audio works in both directions. Additionally, I encountered distorted audio, and I solved it using this patch: pion/mediadevices#500
Thank you @malykhin for your time and support; I appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants