[pulseaudio-discuss] Map sink-input to virtual microphone
guest271314
guest271314 at gmail.com
Tue Dec 22 07:04:46 UTC 2020
This is the code that I cobbled together from your post,
https://askubuntu.com/questions/60837 and
https://aweirdimagination.net/2020/07/19/virtual-microphone-using-gstreamer-and-pulseaudio/
pactl load-module module-combine-sink \
sink_name=Web_Speech_Sink slaves=$(pacmd list-sinks | grep -A1 "* index" |
grep -oP "<\K[^ >]+") \
sink_properties=device.description="Web_Speech_Stream" \
format=s16le \
channels=1 \
rate=22050
pactl move-sink-input $(pacmd list-sink-inputs|tac|perl
-E'undef$/;$_=<>;/speech-dispatcher-espeak-ng.*?index: (\d+)\n/s;say $1')
Web_Speech_Sink
pactl load-module module-remap-source \ master=Web_Speech_Sink.monitor \
source_name=Web_Speech_Monitor \
source_properties=device.description=Web_Speech_Output
Using this approach I am able to capture output from only
speech-dispatcher-espeak-ng module using
navigator.mediaDevices.getUserMedia({audio: true})
.then(async stream => {
const [track] = stream.getAudioTracks();
const devices = await navigator.mediaDevices.enumerateDevices();
const device = devices.find(({label}) => label === 'Web_Speech_Output');
track.stop();
console.log(devices, device);
return navigator.mediaDevices.getUserMedia({audio: {deviceId: {exact:
device.deviceId}}});
})
.then(stream => {
const recorder = new MediaRecorder(stream);
recorder.ondataavailable = e => console.log(URL.createObjectURL(e.data));
const synth = speechSynthesis;
const u = new SpeechSynthesisUtterance('test, test, then test again');
u.onstart = e => {
recorder.start();
console.log(e);
}
u.onend = e => {
recorder.stop();
recorder.stream.getTracks().forEach(track => track.stop());
console.log(e);
}
synth.speak(u);
});
Can the pactl and pacmd code be reduced?
On Tue, Dec 22, 2020 at 2:53 AM Arun Raghavan <arun at arunraghavan.net> wrote:
> On Mon, 21 Dec 2020, at 9:52 AM, guest271314 wrote:
> > A virtual microphone can be created using module-remap-source
> >
> https://aweirdimagination.net/2020/07/19/virtual-microphone-using-gstreamer-and-pulseaudio/
> >
> > pactl load-module module-remap-source \ master=virtmic.monitor
> > source_name=virtmic \
> > source_properties=device.description=Virtual_Microphone
> >
> > AFAICT a sink-input cannot be set as the source for the virtual
> microphone.
> >
> > A sink-input can be recorded using parec or parecord --monitor-stream
> option
> >
> > parecord -v -r --monitor-stream=26 --file-format=wav output.wav
> >
> > How to set a sink-input as source for the virtual microphone so that
> > the output of the sink-input is still played back to speakers or
> > headphones and simultaneously is the source of the virtual microphone?
>
> You could use module-combine-sink to play that sink input to a null-sink
> and the real sink, and then use the null-sink's monitor as your source.
>
> -- Arun
> _______________________________________________
> pulseaudio-discuss mailing list
> pulseaudio-discuss at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20201222/d49326c6/attachment-0001.htm>
More information about the pulseaudio-discuss
mailing list