33 *
44 * Created on: Oct 26.2018
55 *
6- * Version 3.0.6b
7- * Updated on: Sep 25 .2023
6+ * Version 3.0.7
7+ * Updated on: Oct 08 .2023
88 * Author: Wolle (schreibfaul1)
99 *
1010 */
1515#include " opus_decoder/opus_decoder.h"
1616#include " vorbis_decoder/vorbis_decoder.h"
1717
18- #ifdef SDFATFS_USED
19- fs::SDFATFS SD_SDFAT;
20- #endif
21-
2218// ---------------------------------------------------------------------------------------------------------------------
2319AudioBuffer::AudioBuffer (size_t maxBlockSize) {
2420 // if maxBlockSize isn't set use defaultspace (1600 bytes) is enough for aac and mp3 player
@@ -654,19 +650,6 @@ bool Audio::setFileLoop(bool input){
654650// ---------------------------------------------------------------------------------------------------------------------
655651void Audio::UTF8toASCII (char * str){
656652
657- #ifdef SDFATFS_USED
658- // UTF8->UTF16 (lowbyte)
659- const uint8_t ascii[60 ] = {
660- // 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148 // UTF8(C3)
661- // Ä Å Æ Ç É Ñ // CHAR
662- 000 , 000 , 000 , 0xC4 , 143 , 0xC6 ,0xC7 , 000 ,0xC9 ,000 , 000 , 000 , 000 , 000 , 000 , 000 , 0xD1 , 000 , 000 , 000 , // ASCII (Latin1)
663- // 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168
664- // Ö Ü ß à ä å æ è
665- 000 , 0xD6 ,000 , 000 , 000 , 000 , 000 , 0xDC , 000 , 000 , 0xDF ,0xE0 , 000 , 000 , 000 ,0xE4 ,0xE5 ,0xE6 , 000 ,0xE8 ,
666- // 169, 170, 171, 172. 173. 174. 175, 176, 177, 179, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188
667- // ê ë ì î ï ñ ò ô ö ù û ü
668- 000 , 0xEA , 0xEB ,0xEC , 000 ,0xEE ,0xEB , 000 ,0xF1 ,0xF2 , 000 ,0xF4 , 000 ,0xF6 , 000 , 000 ,0xF9 , 000 ,0xFB ,0xFC };
669- #else
670653 const uint8_t ascii[60 ] = {
671654 // 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148 // UTF8(C3)
672655 // Ä Å Æ Ç É Ñ // CHAR
@@ -677,7 +660,6 @@ void Audio::UTF8toASCII(char* str){
677660 // 169, 170, 171, 172. 173. 174. 175, 176, 177, 179, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188
678661 // ê ë ì î ï ñ ò ô ö ù û ü
679662 000 , 136 , 137 , 141 , 000 , 140 , 139 , 000 , 164 , 149 , 000 , 147 , 000 , 148 , 000 , 000 , 151 , 000 , 150 , 129 };
680- #endif
681663
682664 uint16_t i = 0 , j=0 , s = 0 ;
683665 bool f_C3_seen = false ;
@@ -745,13 +727,7 @@ bool Audio::connecttoFS(fs::FS &fs, const char* path, int32_t resumeFilePos) {
745727 m_file_size = audiofile.size ();// TEST loop
746728
747729 char * afn = NULL ; // audioFileName
748-
749- #ifdef SDFATFS_USED
750- audiofile.getName (m_chbuf, m_chbufSize); // #426
751- afn = strdup (m_chbuf);
752- #else
753730 afn = strdup (audiofile.name ());
754- #endif
755731
756732 uint8_t dotPos = lastIndexOf (afn, " ." );
757733 for (uint8_t i = dotPos + 1 ; i < strlen (afn); i++){
@@ -833,105 +809,6 @@ bool Audio::connecttospeech(const char* speech, const char* lang){
833809 return true ;
834810}
835811// ---------------------------------------------------------------------------------------------------------------------
836- bool Audio::connecttomarytts (const char * speech, const char * lang, const char * voice){
837-
838- // lang: fr, te, ru, en_US, en_GB, sv, lb, tr, de, it
839-
840- // voice: upmc-pierre-hsmm fr male hmm
841- // upmc-pierre fr male unitselection general
842- // upmc-jessica-hsmm fr female hmm
843- // upmc-jessica fr female unitselection general
844- // marylux lb female unitselection general
845- // istc-lucia-hsmm it female hmm
846- // enst-dennys-hsmm fr male hmm
847- // enst-camille-hsmm fr female hmm
848- // enst-camille fr female unitselection general
849- // dfki-spike-hsmm en_GB male hmm
850- // dfki-spike en_GB male unitselection general
851- // dfki-prudence-hsmm en_GB female hmm
852- // dfki-prudence en_GB female unitselection general
853- // dfki-poppy-hsmm en_GB female hmm
854- // dfki-poppy en_GB female unitselection general
855- // dfki-pavoque-styles de male unitselection general
856- // dfki-pavoque-neutral-hsmm de male hmm
857- // dfki-pavoque-neutral de male unitselection general
858- // dfki-ot-hsmm tr male hmm
859- // dfki-ot tr male unitselection general
860- // dfki-obadiah-hsmm en_GB male hmm
861- // dfki-obadiah en_GB male unitselection general
862- // cmu-slt-hsmm en_US female hmm
863- // cmu-slt en_US female unitselection general
864- // cmu-rms-hsmm en_US male hmm
865- // cmu-rms en_US male unitselection general
866- // cmu-nk-hsmm te female hmm
867- // cmu-bdl-hsmm en_US male hmm
868- // cmu-bdl en_US male unitselection general
869- // bits4 de female unitselection general
870- // bits3-hsmm de male hmm
871- // bits3 de male unitselection general
872- // bits2 de male unitselection general
873- // bits1-hsmm de female hmm
874- // bits1 de female unitselection general
875-
876- xSemaphoreTake (mutex_audio, portMAX_DELAY);
877-
878- setDefaults ();
879- char host[] = " mary.dfki.de" ;
880- char path[] = " /process" ;
881- int port = 59125 ;
882-
883- uint16_t speechLen = strlen (speech);
884- uint16_t speechBuffLen = speechLen + 300 ;
885- memcpy (m_lastHost, speech, 256 );
886- char * speechBuff = (char *)malloc (speechBuffLen);
887- if (!speechBuff) {log_e (" out of memory" );
888- xSemaphoreGive (mutex_audio);
889- return false ;
890- }
891- memcpy (speechBuff, speech, speechLen);
892- speechBuff[speechLen] = ' \0 ' ;
893- urlencode (speechBuff, speechBuffLen);
894-
895- char resp[strlen (speechBuff) + 200 ] = " " ;
896- strcat (resp, " GET " );
897- strcat (resp, path);
898- strcat (resp, " ?INPUT_TEXT=" );
899- strcat (resp, speechBuff);
900- strcat (resp, " &INPUT_TYPE=TEXT" );
901- strcat (resp, " &OUTPUT_TYPE=AUDIO" );
902- strcat (resp, " &AUDIO=WAVE_FILE" );
903- strcat (resp, " &LOCALE=" );
904- strcat (resp, lang);
905- strcat (resp, " &VOICE=" );
906- strcat (resp, voice);
907- strcat (resp, " HTTP/1.1\r\n " );
908- strcat (resp, " Host: " );
909- strcat (resp, host);
910- strcat (resp, " \r\n " );
911- strcat (resp, " User-Agent: Mozilla/5.0 \r\n " );
912- strcat (resp, " Accept-Encoding: identity\r\n " );
913- strcat (resp, " Accept: text/html\r\n " );
914- strcat (resp, " Connection: close\r\n\r\n " );
915-
916- if (speechBuff){free (speechBuff); speechBuff = NULL ;}
917- _client = static_cast <WiFiClient*>(&client);
918- if (!_client->connect (host, port)) {
919- log_e (" Connection failed" );
920- xSemaphoreGive (mutex_audio);
921- return false ;
922- }
923- _client->print (resp);
924-
925- m_streamType = ST_WEBFILE;
926- m_f_running = true ;
927- m_f_ssl = false ;
928- m_f_tts = true ;
929- setDatamode (HTTP_RESPONSE_HEADER);
930-
931- xSemaphoreGive (mutex_audio);
932- return true ;
933- }
934- // ---------------------------------------------------------------------------------------------------------------------
935812void Audio::urlencode (char * buff, uint16_t buffLen, bool spacesOnly) {
936813
937814 uint16_t len = strlen (buff);
@@ -2890,13 +2767,7 @@ void Audio::processLocalFile() {
28902767 return ;
28912768 } // loop
28922769
2893- #ifdef SDFATFS_USED
2894- audiofile.getName (m_chbuf, m_chbufSize); // #426
2895- char *afn =strdup (m_chbuf);
2896- #else
28972770 char *afn =strdup (audiofile.name ()); // store temporary the name
2898- #endif
2899-
29002771 m_f_running = false ;
29012772 m_streamType = ST_NONE;
29022773 audiofile.close ();
0 commit comments