Skip to content

Commit 80c8048

Browse files
committed
SDFAT and connectToMary removed
1 parent 224373c commit 80c8048

File tree

2 files changed

+4
-177
lines changed

2 files changed

+4
-177
lines changed

src/Audio.cpp

Lines changed: 2 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
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
*/
@@ -15,10 +15,6 @@
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
//---------------------------------------------------------------------------------------------------------------------
2319
AudioBuffer::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
//---------------------------------------------------------------------------------------------------------------------
655651
void 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-
//---------------------------------------------------------------------------------------------------------------------
935812
void 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();

src/Audio.h

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,30 @@
33
*
44
* Created on: Oct 28,2018
55
*
6-
* Version 3.0.6b
7-
* Updated on: Sept 25.2023
6+
* Version 3.0.7
7+
* Updated on: Oct 08.2023
88
* Author: Wolle (schreibfaul1)
99
*/
1010

11-
//#define SDFATFS_USED // activate for SdFat
12-
13-
1411
#pragma once
1512
#pragma GCC optimize ("Ofast")
1613
#include <vector>
1714
#include <Arduino.h>
1815
#include <libb64/cencode.h>
1916
#include <esp32-hal-log.h>
20-
2117
#include <SPI.h>
2218
#include <WiFi.h>
2319
#include <WiFiClientSecure.h>
2420
#include <vector>
2521
#include <driver/i2s.h>
26-
27-
#ifdef SDFATFS_USED
28-
#include <SdFat.h> // https://github.com/greiman/SdFat
29-
#else
3022
#include <SD.h>
3123
#include <SD_MMC.h>
3224
#include <SPIFFS.h>
3325
#include <FS.h>
3426
#include <FFat.h>
35-
#endif // SDFATFS_USED
36-
37-
38-
#ifdef SDFATFS_USED
39-
//typedef File32 File;
40-
typedef FsFile File;
41-
42-
namespace fs {
43-
class FS : public SdFat {
44-
public:
45-
bool begin(SdCsPin_t csPin = SS, uint32_t maxSck = SD_SCK_MHZ(25)) { return SdFat::begin(csPin, maxSck); }
46-
};
47-
48-
class SDFATFS : public fs::FS {
49-
public:
50-
// sdcard_type_t cardType();
51-
uint64_t cardSize() {
52-
return totalBytes();
53-
}
54-
uint64_t usedBytes() {
55-
// set SdFatConfig MAINTAIN_FREE_CLUSTER_COUNT non-zero. Then only the first call will take time.
56-
return (uint64_t)(clusterCount() - freeClusterCount()) * (uint64_t)bytesPerCluster();
57-
}
58-
uint64_t totalBytes() {
59-
return (uint64_t)clusterCount() * (uint64_t)bytesPerCluster();
60-
}
61-
};
62-
}
63-
64-
extern fs::SDFATFS SD_SDFAT;
65-
66-
using namespace fs;
67-
#define SD SD_SDFAT
68-
#endif //SDFATFS_USED
6927

7028
using namespace std;
7129

72-
7330
extern __attribute__((weak)) void audio_info(const char*);
7431
extern __attribute__((weak)) void audio_id3data(const char*); //ID3 metadata
7532
extern __attribute__((weak)) void audio_id3image(File& file, const size_t pos, const size_t size); //ID3 metadata image
@@ -168,7 +125,6 @@ class Audio : private AudioBuffer{
168125
void setBufsize(int rambuf_sz, int psrambuf_sz);
169126
bool connecttohost(const char* host, const char* user = "", const char* pwd = "");
170127
bool connecttospeech(const char* speech, const char* lang);
171-
bool connecttomarytts(const char* speech, const char* lang, const char* voice);
172128
bool connecttoFS(fs::FS &fs, const char* path, int32_t resumeFilePos = -1);
173129
bool connecttoSD(const char* path, int32_t resumeFilePos = -1);
174130
bool setFileLoop(bool input);//TEST loop

0 commit comments

Comments
 (0)