p5.Speech with Microphone Input

Hey,
So I’m trying to make the SpeechRec work with the AudioIn, to adjust the font size according to the volume level.

But for some reason I don’t get any data from the AudioIn, I don’t see anything on the console.

I’m only a beginner, so can you please tell what I’m missing?

Thank you!

var mic;

function setup() {
	mic = new p5.AudioIn();
	mic.start();
	let lang = navigator.language || 'en-US';
	let SpeechRec = new p5.SpeechRec(lang, gotSpeech);

	let continuous = true;
	let interim = true;
	SpeechRec.start(continuous, interim);


function gotSpeech() {
		var vol = mic.getLevel();
		console.log(vol);

		if (SpeechRec.resultValue) {
			createP(SpeechRec.resultString.fontsize(vol+200));
		}
	}

}
1 Like