Page 1 of 1

Bug (or question) with PLAY.SETUP

Posted: Sat Oct 09, 2021 1:04 am
by ebs
If I have the command "play.setup 1" at the beginning of my program (to direct PLAY output to an external DAC), is it "permanent" for the duration of the program?

Here is the program I wrote:
i2c.setup 5, 4
oled.init 1
oled.color 1

play.setup 1
language$ = "en-gb"
voice$ = "Harry"
format$ = "44khz_16bit_mono"
key$ = "" ' removed my key
'play.voicerss "hello!", language$ + "&v=" + voice$ + "&f=" + format$, key$

onUrlMessage urlSpeak
wait

urlSpeak:
say$ = urlmsgget$("speak")
oled.cls
oled.print 0, 0, say$
play.setup 1 ' why is this necessary?
play.voicerss say$, language$ + "&v=" + voice$ + "&f=" + format$, key$
UrlMsgReturn "Message sent back " + time$
return
Note that my actual program has my VoiceRSS key, but I left it out here.

If I uncomment the first "play.voicerss" command, I hear "hello" as expected.
However, I need "play.setup 1" before "play.voicerss" under the "urlSpeak" label or no voice is heard.
Is there a reason for this?

Re: Bug (or question) with PLAY.SETUP

Posted: Sat Oct 09, 2021 7:48 am
by PeterN
Good morning!

In my experience, play.setup 1 sets the external ADC as the audio output and retains it until a reboot or play.setup 0 occurs.
So inserting this only once at the very beginning of the code should ensure the correct output.

I see this strategy in cicciocb' s examples:
[Local Link Removed for Guests]

Without having tested this: Maybe there is a problem with play.voicerss and its last optional parameter "action", which should actually be set to 1 by default?

[Local Link Removed for Guests]
[Local Link Removed for Guests]

Re: Bug (or question) with PLAY.SETUP

Posted: Sat Oct 09, 2021 11:50 am
by PeterN
Now I had the opportunity to test the code and I can not confirm your problem.
It runs well here without the second play.setup .
I am using "Annex32 WiFi CAN 1.43.5" - the version without BLE

Code: [Local Link Removed for Guests]

play.setup 1
language$ = "en-gb"
voice$ = "Harry"
format$ = "44khz_16bit_mono"
key$ = "xxxxxxxxx" ' removed my key
play.voicerss "hello! 1234567890", language$ + "&v=" + voice$ + "&f=" + format$, key$

onUrlMessage urlSpeak
wait
end

urlSpeak:
say$ = urlmsgget$("speak")
play.voicerss say$, language$ + "&v=" + voice$ + "&f=" + format$, key$
UrlMsgReturn |speaking |+say$ +| at |+ time$
return

Re: Bug (or question) with PLAY.SETUP

Posted: Sat Oct 09, 2021 7:21 pm
by ebs
I figured it out, but I don't understand it. :D

There's some kind of interaction between the I2S DAC and the I2C OLED display.
When I removed the I2C and OLED commands, the speech went to the external DAC without the need of the second "PLAY.SETUP 1" command.

Re: Bug (or question) with PLAY.SETUP

Posted: Sat Oct 09, 2021 8:29 pm
by PeterN
You have found the problem and the solution, I think.

I2S uses IO5 as BCLK. [Local Link Removed for Guests]

Your choice for I2C conflicts by using the same IO5 as SDA. [Local Link Removed for Guests]

This should be easy to correct.

Re: Bug (or question) with PLAY.SETUP

Posted: Sat Oct 09, 2021 10:40 pm
by ebs
The ESP-32 board I was using has a built-in OLED display connected to IO4 and IO5, but since I really don't need it, I switched over to a board without the display.

Thanks for your help!