-
-
Save suapapa/d598d99360497252433af430902bb49e to your computer and use it in GitHub Desktop.
package main | |
import ( | |
"encoding/binary" | |
"fmt" | |
"os" | |
"os/signal" | |
"time" | |
"github.com/gordonklaus/portaudio" | |
) | |
func main() { | |
if len(os.Args) < 2 { | |
fmt.Println("missing required argument: output file name") | |
return | |
} | |
fmt.Println("Recording. Press Ctrl-C to stop.") | |
sig := make(chan os.Signal, 1) | |
signal.Notify(sig, os.Interrupt, os.Kill) | |
fileName := os.Args[1] | |
f, err := os.Create(fileName) | |
chk(err) | |
defer func() { | |
chk(f.Close()) | |
}() | |
portaudio.Initialize() | |
time.Sleep(1) | |
defer portaudio.Terminate() | |
in := make([]int16, 64) | |
stream, err := portaudio.OpenDefaultStream(1, 0, 16000, len(in), in) | |
chk(err) | |
defer stream.Close() | |
chk(stream.Start()) | |
loop: | |
for { | |
chk(stream.Read()) | |
chk(binary.Write(f, binary.LittleEndian, in)) | |
select { | |
case <-sig: | |
break loop | |
default: | |
} | |
} | |
chk(stream.Stop()) | |
} | |
func chk(err error) { | |
if err != nil { | |
panic(err) | |
} | |
} |
Its raw data which can be imported in audio apps like Audacity.
unable to send my voice to another user while on call
unable to send my voice to another user while on call
It's an raw recording test program and still works (tested in Ubuntu 22.04). What is your purpose?
my purpose is to record audio for interview purpose but unable to do so as it's either not able to send the voice to another user or unable to record voice of another person, can u please tell what could be the issue
What's the purpose to create a loop
label here? A for
loop is already provided for an infinite amount of time.
What's the purpose to create a
loop
label here? Afor
loop is already provided for an infinite amount of time.
To break the loop in line 46.
if line 46 is just break
it breaks the switch clause only.
my purpose is to record audio for interview purpose but unable to do so as it's either not able to send the voice to another user or unable to record voice of another person, can u please tell what could be the issue
sniffing other application's mic input sound impossible to me. There could be two solution:
- Record it in the interview program.
- Make virtual mic which record its input.
Good luck!
Little question: when we deploy the app we don't need to install portaudio on the users' machines, right? We just have to do it on our developers machines, correct? Thanks
If you also provide the shared library that the application will link, then no. A static binary also can be an option, but I'm not sure how Go does this.
If I'm using "mpg123 - " to play the output file will it work ?
Which format is used to save the audio? Thanks.