Skip to content

Commit 9da76f4

Browse files
authored
Update Readme.md
1 parent 5ca322b commit 9da76f4

File tree

1 file changed

+8
-8
lines changed
  • examples/Support for Local TTS function

1 file changed

+8
-8
lines changed

examples/Support for Local TTS function/Readme.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,11 @@ bool Audio::connect_local_tts(const String& host, int port, const String& path,
1111
const String& text, const String& voice_id,
1212
const String& lang, const String& endpoint) {
1313

14-
if (text.isEmpty()) {
15-
AUDIO_INFO("TTS text is empty");
16-
stopSong();
17-
return false;
18-
}
19-
2014
xSemaphoreTakeRecursive(mutex_playAudioData, 0.3 * configTICK_RATE_HZ);
2115
setDefaults();
2216
m_f_ssl = false;
2317
m_f_tts = true;
24-
m_speechtxt.assign(text.c_str());
18+
m_speechtxt.assign(text.c_str()); // need in the audio_info event
2519

2620
String body = "{";
2721
body += "\"text\":\"" + text + "\"";
@@ -39,6 +33,7 @@ bool Audio::connect_local_tts(const String& host, int port, const String& path,
3933
req += body;
4034

4135
_client = static_cast<WiFiClient*>(&client);
36+
4237
AUDIO_INFO("Connecting to local TTS server %s:%d", host.c_str(), port);
4338

4439
if (!_client->connect(host.c_str(), port)) {
@@ -52,6 +47,7 @@ bool Audio::connect_local_tts(const String& host, int port, const String& path,
5247
m_f_running = true;
5348
m_dataMode = HTTP_RESPONSE_HEADER;
5449
m_lastHost.assign(host.c_str());
50+
m_currentHost.assign(host.c_str()); // required else an error will show up (m_currentHost is empty).
5551

5652
if (endpoint == "gtts" || endpoint == "edge_tts") {
5753
m_expectedCodec = CODEC_MP3;
@@ -62,8 +58,12 @@ bool Audio::connect_local_tts(const String& host, int port, const String& path,
6258
xSemaphoreGiveRecursive(mutex_playAudioData);
6359
return true;
6460
}
65-
6661
```
62+
Also there may be a need to increase the timeout otherwise error like below will pop on slow servers
63+
64+
info Audio.cpp:3956: timeout
65+
[530903][I][NetworkClient.cpp:265] connect(): select returned due to timeout 3000 ms for fd 48
66+
6767
6868
And this can be used with a simple Python Server running locally :
6969
```py

0 commit comments

Comments
 (0)