Skip to content

Commit

Permalink
Version 0.6
Browse files Browse the repository at this point in the history
Resolve Google TTS problems thanks to adding support for "Tranfer-Encoding: chunked streams"

Included changes from yoav-klein and DeqingSun to manage correctly Google TTS.
See here for details :
earlephilhower/ESP8266Audio#394
  • Loading branch information
schmurtzm committed Feb 22, 2022
1 parent 26e84c2 commit f95a519
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 19 deletions.
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
# MrDiy Audio Notifier - Schmurtz Edition
----
MrDiy Audio Notifier is an audio player controlled by MQTT.

It is able to :
- play local TTS (samvoice)
- play Google Translate TTS
- play MP3, AAC and FLAC
- play RTTTL (Nokia ringtones)
- play some web radio

MrDiy Audio Notifier is based on esp8266audio library. This repo uses most of the MrDiy's code with some modifications :

MrDiy Audio Notifier is based on esp8266audio library. This repo uses most of the MrDiy's code with some modifications :

- Ported to platformio (with differents recommanded settings for ESP8266audio)
- Can be compiled for ESP8266 and ESP32
- IotWebConf updated to version v3.x (thanks to Markvader)
- Google Translate TTS (multilingual and better voice quality than the local ESP8266SAM). [List of supported languages](https://github.com/florabtw/google-translate-tts/blob/master/src/voices.js).
- ability to play AAC (required for many web radio) and flac (not tested)
- Set voice style of samvoice
- Ability to play AAC (required for many web radio) and flac (not tested)
- New settings in web interface allow to switch easily between no DAC (version used by mr DIY) , external DAC or internal DAC (for ESP32).
- Set volume with physical buttons
- Documentation to connect your ESP to a speaker (see comments at the top of the "main.cpp" file)
- You’ll also find some useful comments for wiring your DAC quickly or to improve the code (sound level of RTTTS, ssl, IotWebConf migration to v3.x...).
- ...
Expand Down Expand Up @@ -39,12 +49,14 @@
/* * default TTS google voice language can be set in web interface */
/* - NEW: Firmware update with web interface */
/* - NEW: MQTT command feedback msg when a problems are detected (topic "answer") */
/* - FIX : longer MQTT server name are supported */
/* - FIX: longer MQTT server name are supported */
/* - Breaking change : MQTT TTS commands renamed: samvoice /googlevoice */
/* - Less different firmwares + Schmurtz_ESP_Flasher : Windows script for easy flashing */
/* V0.5 - 2022/02/18 : */
/* - NEW: increase and decrease volume with MQTT commands */
/* - NEW: increase and decrease volume physical buttons on GPIO */
/* V0.6 - 2022/02/22 : */
/* - FIX: Google TTS : a lot better, almost no hang */
```

How to flash :
Expand Down Expand Up @@ -80,7 +92,7 @@ To flash it, plug your ESP in USB port, download this full repo and then run _Sc

- Play an Icecast Stream MQTT topic: "your_mqtt_topic/stream"
MQTT load: http://url-to-the-icecast-stream/file.mp3
example: http://22203.live.streamtheworld.com/WHTAFM.mp3
example: http://icecast.radiofrance.fr/fiprock-midfi.mp3

- Play a Flac MQTT topic: "your_mqtt_topic/flac"
(better for ESP32, hard for esp8266)
Expand Down Expand Up @@ -139,13 +151,18 @@ You may also want to add a 220uF cap from USB 5V to GND just to help filter out

Known issues :
----
- Playing GoogleTTS hang the ESP at end of playing (for both ESP8266 and ESP32) : [issue #395](https://github.com/earlephilhower/ESP8266Audio/issues/395)
- Playing GoogleTTS hang the ESP at end of playing (for both ESP8266 and ESP32) : [issue #395](https://github.com/earlephilhower/ESP8266Audio/issues/395) (almost resolved)
- <strike>Playing RTTTL (nokia tone) never stop playing the last note (ESP32 only) :</strike> [issue #327 resolved](https://github.com/earlephilhower/ESP8266Audio/issues/327)

These issues are related to [ESP8266audio library](https://github.com/earlephilhower/ESP8266Audio) so it has been created on their repo ;)



Use with Home Assistant :
----
It is possible to use MrDiy Notifier as a media player entity.
See my post on community forum for it :
https://community.home-assistant.io/t/turn-an-esp8266-wemosd1mini-into-an-audio-notifier-for-home-assistant-play-mp3-tts-rttl/211499/130?u=schmurtz


===========================================================================
Expand Down
4 changes: 2 additions & 2 deletions _Schmurtz_ESP_Flasher/Schmurtz_ESP_Flasher.bat
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ echo+
set /p userinp= ^> Select Option :


if /i "%userinp%"=="1" set Selected_Firmware=FW_v0.5_ESP32_esp32doit-devkit-v4.bin & goto :FlashESP32
if /i "%userinp%"=="2" set Selected_Firmware=FW_v0.5_ESP8266_d1_mini.bin & goto :FlashESP8266
if /i "%userinp%"=="1" set Selected_Firmware=FW_v0.6_ESP32_esp32doit-devkit-v4.bin & goto :FlashESP32
if /i "%userinp%"=="2" set Selected_Firmware=FW_v0.6_ESP8266_d1_mini.bin & goto :FlashESP8266
if /i "%userinp%"=="X" goto :EraseFlash
if /i "%userinp%"=="C" goto :com_port
if /i "%userinp%"=="Q" exit
Expand Down
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ lib_ldf_mode = deep
lib_deps =
knolleary/PubSubClient
horihiro/esp8266-google-tts
https://github.com/earlephilhower/ESP8266Audio.git ; dev version to have last commits, stable version : earlephilhower/ESP8266Audio
; https://github.com/earlephilhower/ESP8266Audio.git ; dev version to have last commits, stable version : earlephilhower/ESP8266Audio
https://github.com/schmurtzm/ESP8266Audio.git ; Temporary version to solve Google TTS problems
https://github.com/earlephilhower/ESP8266SAM.git ; earlephilhower/ESP8266SAM
prampec/IotWebConf ; V3.x of IotWebConf

Expand Down
23 changes: 12 additions & 11 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,16 +716,12 @@ void onMqttMessage(char *topic, byte *payload, unsigned int mlength)
Serial.println(strcmp(soundOutputValue,"INTERNAL_DAC"));
if (strcmp(soundOutputValue,"INTERNAL_DAC") == 0 || strcmp(soundOutputValue,"EXTERNAL_DAC") == 0)
{
sam->Say(out, newMsg);
Serial.print("---------- >");
sam->Say(out, newMsg);
Serial.print(soundOutputValue);
Serial.println("--------");

}else{
sam->Say(outNoDac, newMsg);
Serial.print("--+++++++++++ >");
sam->Say(outNoDac, newMsg);
Serial.print(soundOutputValue);
Serial.println("--------");
}


Expand Down Expand Up @@ -765,10 +761,14 @@ Serial.println(strcmp(soundOutputValue,"INTERNAL_DAC"));

//String StrnewMsg = String((char *)payload);
int index = StrnewMsg.lastIndexOf(','); // take position of the last ","
if (index < LANGMAXLENGTH) // it could be a language parameter, let's check if it exists in the list...
Serial.println(__LINE__);
Serial.println(index);
Serial.println(StrnewMsg.length() );
Serial.println(StrnewMsg.length() - index);
if ( StrnewMsg.length() - index <= LANGMAXLENGTH) // it could be a language parameter, let's check if it exists in the list...
{
SelectedLanguage = StrnewMsg.substring(index + 1); // a new string which contains what's after the last ","

Serial.println(SelectedLanguage);
for (int i = 0; i < (sizeof(allowedLang) / sizeof(allowedLang[1])) -1; i++)
{
if (strcmp(allowedLang[i],SelectedLanguage.c_str())==0) KnownLanguage = true; // checking if current language is contained in the list
Expand Down Expand Up @@ -803,11 +803,12 @@ Serial.println(strcmp(soundOutputValue,"INTERNAL_DAC"));

// char buffer[GoogleUrl.length() + 1];
// GoogleUrl.toCharArray(buffer, GoogleUrl.length() + 1);
file_http = new AudioFileSourceHTTPStream();
if (file_http->open( (const char *)GoogleUrl.c_str()))
file_icy = new AudioFileSourceICYStream();
if (file_icy->open( (const char *)GoogleUrl.c_str()))
{
broadcastStatus("status", "playing");
buff = new AudioFileSourceBuffer(file_http, preallocateBuffer, preallocateBufferSize);
//updateLEDBrightness(50); // dim while playing
buff = new AudioFileSourceBuffer(file_icy, preallocateBuffer, preallocateBufferSize);
mp3 = new AudioGeneratorMP3();
if (strcmp(soundOutputValue,"INTERNAL_DAC") == 0 || strcmp(soundOutputValue,"EXTERNAL_DAC") == 0)
{
Expand Down

0 comments on commit f95a519

Please sign in to comment.