Page 1 of 1

wav file input with headset output

Posted: Mon Apr 29, 2024 8:01 pm
by dpoznan
I want to input wav file audio that I have captured or created and then process the audio and output to headset.

I can't see how to do that since it appears that setting iolib = MHAIOFile, commits to doing file I/O and then can't do
headset output.

So I asked chatGPT4 how to do it with openMHA and was informed that I could use a "wavreader" plugin or
mha.algos = [source fileinput]
mha.algos.config = "sourcemhachain:input=file.wav"
mha.algs.fileinput.config = "...."

This appears to be "hallucination" since I cannot find these plugins in openMHA 4.17.0

Any suggestions? Seems like something that should be possible. I would like to do this on both my Mac and PHL
devices.

Thanks,


Dan Poznanovic

Re: wav file input with headset output

Posted: Tue Apr 30, 2024 7:48 am
by hendrikkayser
Hi Dan,

iolib = MHAIOJack and the plugin "addsndfile" at the beginning of your processing chain should do what you want.

Setting
addsndfile.mode = replace
will replace the microphone input signals with the content of your .wav file.


It seems that chatGPT4 did not read the openMHA plugin manual...

Re: wav file input with headset output

Posted: Wed May 01, 2024 11:02 pm
by dpoznan
I cannot get the addsndfile plugin to work. In my code I set usefile to False and I get mic to play on the earbuds.
If I set it to True I do not get an error but I also do not get audio output.

Does anyone have a simple example code that demonstrates the addsndfile plugin?

Here is a snippet of what I am trying to do........


mha_Device.set_val('iolib ',' MHAIOJackdb')
# Mac external mic is a single mic
if usefile==False:
mha_Device.set_val('io.con_in ',' [system:capture_1 system:capture_1]')
# Mac has left & right earphones
mha_Device.set_val('io.con_out ',' [system:playback_1 system:playback_2]')
mha_Device.set_val('mha.algos','[mhachain:adds route:sort_input transducers route:sort_output gain:mute_dummies acmon]')
#mha_Device.set_val('mha.algos','[ route:sort_input addsndfile transducers route:sort_output gain:mute_dummies acmon]')
mha_Device.set_val('mha.adds.algos','[altplugs:alts]')
mha_Device.set_val('mha.adds.alts.plugs','[addsndfile identity]')
if usefile:
mha_Device.set_val('mha.adds.alts.select','addsndfile')
else:
mha_Device.set_val('mha.adds.alts.select','identity')

. . . . .

mha_Device.set_val('mha.adds.alts.addsndfile.filename' , '1speaker_diffNoise_2ch_16k.wav')
mha_Device.set_val('mha.adds.alts.addsndfile.levelmode' , 'rms')
mha_Device.set_val('mha.adds.alts.addsndfile.path' , './')
mha_Device.set_val('mha.adds.alts.addsndfile.channels' , ' [0 1]')
mha_Device.set_val('mha.adds.alts.addsndfile.loop' , 'no')
#mha_Device.set_val('mha.adds.alts.addsndfile.mode' , 'replace')

Re: wav file input with headset output

Posted: Fri May 03, 2024 12:53 pm
by nmichael
Dan,

This is a simple program that plays .wav files. You of course need to put some .wav files on the PHL in the correct place. Chose which file gets played by setting mha.wav.select. Setting mha.wav.select = mic will pass the mic signal through.

Nick
--------------------------------------------------------------------------------------------------

nchannels_in = 2
fragsize = 64
srate = 16000
mhalib = mhachain
iolib = MHAIOJack

mha.algos=[ gain altplugs:wav ]
mha.gain.gains=[ 10 10 ]
mha.wav.plugs = [addsndfile:speech1 addsndfile:speech2 gain:mic ]
mha.wav.select = speech1

mha.wav.speech1.path = /etc/mahalia/mha_configuration/
mha.wav.speech1.filename = male16k.wav
mha.wav.speech1.levelmode = peak
mha.wav.speech1.level = 90
mha.wav.speech1.channels = [ 0 1]
mha.wav.speech1.mode = replace

mha.wav.speech2.path = /etc/mahalia/mha_configuration/
mha.wav.speech2.filename = British_speech16.wav
mha.wav.speech2.levelmode = peak
mha.wav.speech2.level = 90
mha.wav.speech2.channels = [ 0 1]
mha.wav.speech1.mode = replace

mha.wav.mic.gains = [10 10]

io.con_in = [system:capture_1 system:capture_2]
io.con_out = [system:playback_1 system:playback_2]

cmd=start

---------------------------------------------------------------------------