Bug (or question) with PLAY.SETUP

Here we can discuss about the problem found
Post Reply
ebs
Posts: 14
Joined: Fri Jun 25, 2021 2:33 pm
Been thanked: 2 times

Bug (or question) with PLAY.SETUP

Post 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?
User avatar
PeterN
Posts: 366
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 171 times
Been thanked: 203 times
Contact:

Re: Bug (or question) with PLAY.SETUP

Post 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]
User avatar
PeterN
Posts: 366
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 171 times
Been thanked: 203 times
Contact:

Re: Bug (or question) with PLAY.SETUP

Post 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
ebs
Posts: 14
Joined: Fri Jun 25, 2021 2:33 pm
Been thanked: 2 times

Re: Bug (or question) with PLAY.SETUP

Post 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.
User avatar
PeterN
Posts: 366
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 171 times
Been thanked: 203 times
Contact:

Re: Bug (or question) with PLAY.SETUP

Post 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.
ebs
Posts: 14
Joined: Fri Jun 25, 2021 2:33 pm
Been thanked: 2 times

Re: Bug (or question) with PLAY.SETUP

Post 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!
Post Reply