Skip to content

Commit d48f460

Browse files
committed
Initial Load
1 parent 182a234 commit d48f460

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ add_library(simple-tts INTERFACE)
1515
target_include_directories(simple-tts INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src )
1616

1717
# build examples
18-
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/examples" EXCLUDE_FROM_ALL)
18+
#add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/examples" EXCLUDE_FROM_ALL)
19+
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/examples" )

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The result is: NOON
5353

5454
## Text to Speech
5555

56-
If we record the words in mp3 we might even get away with the need of a separate SD drive because we can store the audio in program memory. The ExampleAudioDictionaryValues contains the prerecorded mp3 files which are stored in the progmem.
56+
If we record the words in mp3 we might even get away with the need for a separate SD drive because we can store the audio in program memory. The ExampleAudioDictionaryValues contains the prerecorded mp3 files which are stored in the progmem.
5757

5858
```
5959
#include "SimpleTTS.h"

examples/sd-initial-load-long/sd-initial-load-long.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ AudioSDEntry entries[]= {
2525

2626

2727
AudioDictionarySD sd("/tts","wav"); // store the files in the /tts directory with the wav extension.
28-
const char* url="http://pi.local:5002/api/tts?text=@"; // Mozilla TTS on a Raspberry PI
28+
const char* url="http://192.168.1.34:5002/api/tts?text=@"; // Mozilla TTS on a Raspberry PI
2929
const char* mime="audio/wav";
3030
const char* ssid = "SSID";
3131
const char* password = "password";

examples/sd-initial-load/sd-initial-load.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
NumberToText ntt; // source for number texts
1717
TimeToText ttt; // source for time based texts
1818
AudioDictionarySD sd("/tts","wav"); // store the files in the /tts directory with the wav extension.
19-
const char* url="http://pi.local:5002/api/tts?text=@"; // Mozilla TTS on a Raspberry PI
19+
const char* url="http://192.168.1.34:5002/api/tts?text=@"; // Mozilla TTS on a Raspberry PI
2020
const char* mime="audio/wav";
2121
const char* ssid = "Phil Schatzmann";
2222
const char* password = "sabrina01";
@@ -37,7 +37,7 @@ void connectWifi() {
3737

3838
void setup(){
3939
Serial.begin(115200);
40-
AudioLogger::instance().begin(Serial, AudioLogger::Debug);
40+
AudioLogger::instance().begin(Serial, AudioLogger::Info);
4141
// only for audiokit
4242
//SPI.begin(PIN_AUDIO_KIT_SD_CARD_CLK, PIN_AUDIO_KIT_SD_CARD_MISO, PIN_AUDIO_KIT_SD_CARD_MOSI, PIN_AUDIO_KIT_SD_CARD_CS);
4343

src/AudioDictionarySD.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,11 @@ class AudioDictionarySD : public AudioDictionaryBase {
107107
SD.remove(file);
108108
}
109109
File newFile = SD.open(file, FILE_WRITE);
110-
copy(newFile, url_with_text.c_str(), mime);
111-
newFile.close();
110+
bool ok = copy(newFile, url_with_text.c_str(), mime);
111+
if (!ok){
112+
LOGE("No data available: file '%s' will be deleted", file);
113+
SD.remove(file);
114+
}
112115
}
113116

114117
protected:
@@ -151,13 +154,14 @@ class AudioDictionarySD : public AudioDictionaryBase {
151154
return (const char *)file_path;
152155
}
153156

154-
void copy(File &file, const char *url, const char *mime) {
157+
bool copy(File &file, const char *url, const char *mime) {
155158
url_stream.begin(url, mime);
156159
cp.begin(file, url_stream);
157-
cp.copyAll(0);
160+
bool result = cp.copyAll(0);
158161
url_stream.end();
159162
LOGI("file size: %d Kbyte", (int) file.size() / 1024);
160163
file.close();
164+
return result;
161165
}
162166
};
163167

0 commit comments

Comments
 (0)