diff --git a/README.md b/README.md index 8b5e44e..264477a 100644 --- a/README.md +++ b/README.md @@ -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...). - ... @@ -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 : @@ -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) @@ -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) - Playing RTTTL (nokia tone) never stop playing the last note (ESP32 only) : [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 =========================================================================== diff --git a/_Schmurtz_ESP_Flasher/Schmurtz_ESP_Flasher.bat b/_Schmurtz_ESP_Flasher/Schmurtz_ESP_Flasher.bat index 97105ae..ded2149 100644 --- a/_Schmurtz_ESP_Flasher/Schmurtz_ESP_Flasher.bat +++ b/_Schmurtz_ESP_Flasher/Schmurtz_ESP_Flasher.bat @@ -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 diff --git a/_Schmurtz_ESP_Flasher/firmwares/FW_v0.6_ESP32_esp32doit-devkit-v4.bin b/_Schmurtz_ESP_Flasher/firmwares/FW_v0.6_ESP32_esp32doit-devkit-v4.bin new file mode 100644 index 0000000..752bdfa Binary files /dev/null and b/_Schmurtz_ESP_Flasher/firmwares/FW_v0.6_ESP32_esp32doit-devkit-v4.bin differ diff --git a/_Schmurtz_ESP_Flasher/firmwares/FW_v0.6_ESP8266_d1_mini.bin b/_Schmurtz_ESP_Flasher/firmwares/FW_v0.6_ESP8266_d1_mini.bin new file mode 100644 index 0000000..899c048 Binary files /dev/null and b/_Schmurtz_ESP_Flasher/firmwares/FW_v0.6_ESP8266_d1_mini.bin differ diff --git a/platformio.ini b/platformio.ini index ff089e7..a01df2e 100644 --- a/platformio.ini +++ b/platformio.ini @@ -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 diff --git a/src/main.cpp b/src/main.cpp index 12cdcda..bba5ee2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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("--------"); } @@ -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 @@ -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) {