problem recording audio with the R language audio package

28 Views Asked by At

I am having a problem recording audio with the R language "audio" package.

I cannot get a sound recorded.

I am using a late model mac mini, OS Sonoma 14.2.1

I have installed and loaded the audio package in my R Console:

> current.audio.driver()
[1] "macosx"

I have an external microphone connected: I can use System Settings Sound tab to show that my voice is picked up by the microphone I can communicate with Siri through this microphone I can record my voice using Voice Memos app

I can hear the sound when I issue:

play(sin(1:10000/20))

But when I run the commands given in the documentation, I get no recording:

> #Set our recording time
> rec_time <- 5 
> 
> #Recording
> Samples<-rep(NA_real_, 44100 * rec_time) #Defining number of samples recorded
> print("Start speaking")
[1] "Start speaking"
> audio_obj <-record(Samples, 44100, 1) #Create an audio instance with sample rate 44100 and mono channel [I can use System Settings Sound tab to show that my voice is picked up by the microphone at the same time that I am running this "record"][I can record using Voice Memos at the same time]
> wait(6)
> rec <- audio_obj$data # get the recorded data from the audio object
>  
> which(rec!=0)
integer(0)
> play(rec) [NO SOUND]

I expected to use my external microphone to record my speaking voice, but the recording contained no sound.

0

There are 0 best solutions below