-
Notifications
You must be signed in to change notification settings - Fork 118
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
How to play audio file? #13
Comments
There's a command line tool called sox that makes it easy to convert audio files to the format needed by gosip, which is signed linear 16-bit samples at 8khz. For example:
To get started playing audio files in a telephone calls, you can modify the fone/main.go example so it reads audio from a file rather than your microphone. The ticker.C channel is triggered every 20 milliseconds. Each time that happens, you need to read 320 bytes from the file and pass it along to rtp.Send(). I recommend the audio files be converted to s16 beforehand, so decoding is a one-time cost. If you want to play arbitrary audio formats on the fly, one thing that works great is spawning sox as a subprocess and reading the samples via a pipe. That should minimize the chance of cpu-bound audio decoding disrupting the event loop, which for PSTN calls must behave like real time. |
Can you provide the param format? |
The URI format depends. If you're calling the PSTN you need to use a service like Flowroute. If you do that they'll give you a prefix. If you wanted to dial a number in New York it'd look something like this:
If you want to dial a software telephone, usually they'll speak sip natively and the SIP URI will end up looking more like an email address. |
me try "go run ./fone/main.go sip:2001@sip-test.pudutech.com" me running in docker,whether the influence? |
I would recommend contacting your local administrator and troubleshooting the problem on your end. |
me find fone/main.go, but only find use mic |
Open it as a normal file using the Go standard library. Please note this project supports gosip but we can't provide technical support in general. |
Thank you very much for your answer |
Thx you @jart for your awesome library! I'm using the echo_test example code to make a SIP phone call from a Go application to another soft phone. I have FreeSwitch configured, and the Go app successfully send INVITE to soft phone, but I have trouble and really need your help: I can't hear anything from soft phone Some clues1/ Here is my modified code 2/ The audio file is in right format:
Note: I also try these but no luck:
3/ Application log
|
Hi @yaosiqi525 , did you get it work with your audio file? |
@yaosiqi525 @hoangtuan151 you can try to get this library(zaf/g711) |
I need play mp3 or wav file, do you know what lib can help me ?
Thanks!!!
The text was updated successfully, but these errors were encountered: