This commit is contained in:
2026-02-12 21:00:02 -08:00
parent 77f8236347
commit 8bdbf227ca
1141 changed files with 1010880 additions and 2 deletions

View File

@@ -0,0 +1,3 @@
# Examples for the WebServer
I created the Server as a simple way to test the audio w/o any need of soldering or connecting any wires. Just use the Wifi to listen to your audio...

View File

@@ -0,0 +1,25 @@
# A Simple SdFat Audio Player
The example demonstrates how to implement an __MP3 Player__: which provides the data from a SD drive and provides the audio via a Webserver!
## SD Card
Here is the information how to wire the SD card to the ESP32
| SD | ESP32
|-------|-----------------------
| CS | VSPI-CS0 (GPIO 05)
| SCK | VSPI-CLK (GPIO 18)
| MOSI | VSPI-MOSI (GPIO 23)
| MISO | VSPI-MISO (GPIO 19)
| VCC | VIN (5V)
| GND | GND
![SD](https://www.pschatzmann.ch/wp-content/uploads/2021/04/sd-module.jpeg)
## Dependencies
- https://github.com/pschatzmann/arduino-audio-tools
- https://github.com/pschatzmann/TinyHttp.git
- Arduino SD library

View File

@@ -0,0 +1,54 @@
/**
* @file player-sdfat-a2dp.ino
* @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-player/player-sdfat-a2dp/README.md
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/Disk/AudioSourceSD.h"
#include "AudioTools/Communication/AudioServerEx.h"
#include "AudioTools/AudioCodecs/CodecCopy.h"
#define PIN_AUDIO_KIT_SD_CARD_CS 13
#define PIN_AUDIO_KIT_SD_CARD_MISO 2
#define PIN_AUDIO_KIT_SD_CARD_MOSI 15
#define PIN_AUDIO_KIT_SD_CARD_CLK 14
const char *ssid = "SSID";
const char *password = "PWD";
const char *startFilePath="/";
const char* ext="mp3";
AudioSourceSD source(startFilePath, ext, PIN_AUDIO_KIT_SD_CARD_CS);
AudioServerEx out;
AudioPlayer player(source, out, *new CopyDecoder());
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
HttpLogger.setLevel(tinyhttp::Warning);
// setup SPI for SD card
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);
// setup output - We need to login and serve the data as audio/mp3
auto cfg = out.defaultConfig();
cfg.password = password;
cfg.ssid = ssid;
cfg.mime = "audio/mp3";
out.begin(cfg);
// setup player
player.setVolume(1.0);
player.begin();
}
void loop() {
player.copy();
out.copy();
}

View File

@@ -0,0 +1,5 @@
This directory contains a server in Python that was used to test the [Arduino
post sketch](https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-communication/http-client/streams-http_post/streams-http_post.ino) using chunged writes.
The server logs each written line and writes the data to a file.

View File

@@ -0,0 +1,48 @@
#!/usr/bin/env python3
from http.server import HTTPServer, SimpleHTTPRequestHandler
HOST = ""
PORT = 9988
path = "./audio.pcm"
class TestHTTPRequestHandler(SimpleHTTPRequestHandler):
def do_POST(self):
self.send_response(200)
self.end_headers()
if "Content-Length" in self.headers:
content_length = int(self.headers["Content-Length"])
body = self.rfile.read(content_length)
with open(path, "wb") as out_file:
print("writing:", content_length)
out_file.write(body)
elif "chunked" in self.headers.get("Transfer-Encoding", ""):
with open(path, "wb") as out_file:
while True:
line = self.rfile.readline().strip()
print(line)
chunk_length = int(line, 16)
if chunk_length != 0:
print("writing chunk:", chunk_length)
chunk = self.rfile.read(chunk_length)
out_file.write(chunk)
# Each chunk is followed by an additional empty newline
# that we have to consume.
self.rfile.readline()
# Finally, a chunk size of 0 is an end indication
if chunk_length == 0:
break
def main():
httpd = HTTPServer((HOST, PORT), TestHTTPRequestHandler)
print("Serving at port:", httpd.server_port)
httpd.serve_forever()
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,56 @@
/**
* @file streams-audiokit-webserver_aac.ino
*
* This sketch reads sound data from the AudioKit. The result is provided as AAC stream which can be listened to in a Web Browser
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/AudioCodecs/CodecAACFDK.h"
#include "AudioTools/Communication/AudioHttp.h"
// WIFI
const char *ssid = "ssid";
const char *password = "password";
AudioInfo info(16000,1,16);
AACEncoderFDK fdk;
AudioEncoderServer server(&fdk, ssid, password);
AudioBoardStream kit(AudioKitEs8388V1);
// Arduino setup
void setup(){
Serial.begin(115200);
// Defining Loglevels for the different libraries
//AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
//LOGLEVEL_FDK = FDKInfo;
//LOGLEVEL_AUDIOKIT = AudioKitInfo;
// setup and configure fdk (not necessary if you activate PSRAM)
fdk.setAudioObjectType(2); // AAC low complexity
fdk.setOutputBufferSize(1024); // decrease output buffer size
fdk.setVariableBitrateMode(2); // low variable bitrate
// start i2s input with default configuration
Serial.println("starting AudioKit...");
auto config = kit.defaultConfig(RX_MODE);
config.input_device = ADC_INPUT_LINE2;
config.copyFrom(info);
config.sd_active = false;
kit.begin(config);
Serial.println("AudioKit started");
// start data sink
server.begin(kit, info);
Serial.println("Server started");
}
// Arduino loop
void loop() {
// Handle new connections
server.doLoop();
}

View File

@@ -0,0 +1,63 @@
/**
* @file streams-audiokit-webserver_mp3.ino
*
* This sketch reads sound data from the AudioKit. The result is provided as MP3 stream which can be listened to in a Web Browser
*
* @author Phil Schatzmann, Thorsten Godau (changed AAC example to MP3, added optional static IP)
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/AudioCodecs/CodecMP3LAME.h"
#include "AudioTools/Communication/AudioHttp.h"
// Set static IP address and stuff (optional)
IPAddress IPA_address(192, 168, 0, 222);
IPAddress IPA_gateway(192, 168, 0, 1);
IPAddress IPA_subnet(255, 255, 0, 0);
IPAddress IPA_primaryDNS(192, 168, 0, 1); //optional
IPAddress IPA_secondaryDNS(8, 8, 8, 8); //optional
// WIFI
const char *ssid = "ssid";
const char *password = "password";
AudioInfo info(16000,1,16);
MP3EncoderLAME mp3;
AudioEncoderServer server(&mp3, ssid, password);
AudioBoardStream kit(AudioKitEs8388V1);
// Arduino setup
void setup(){
Serial.begin(115200);
// Defining Loglevels for the different libraries
//AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
//LOGLEVEL_AUDIOKIT = AudioKitInfo;
// Configures static IP address (optional)
if (!WiFi.config(IPA_address, IPA_gateway, IPA_subnet, IPA_primaryDNS, IPA_secondaryDNS))
{
Serial.println("WiFi.config: Failed to configure static IPv4...");
}
// start i2s input with default configuration
Serial.println("starting AudioKit...");
auto config = kit.defaultConfig(RX_MODE);
config.input_device = ADC_INPUT_LINE2;
config.copyFrom(info);
config.sd_active = false;
kit.begin(config);
Serial.println("AudioKit started");
// start data sink
server.begin(kit, config);
Serial.println("Server started");
}
// Arduino loop
void loop() {
// Handle new connections
server.doLoop();
}

View File

@@ -0,0 +1,39 @@
/**
* @file streams-audiokit-webserver_wav.ino
*
* This sketch reads sound data from the AudioKit. The result is provided as WAV stream which can be listened to in a Web Browser
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/AudioLibs/AudioBoardStream.h"
#include "AudioTools/Communication/AudioHttp.h"
AudioEncoderServer server(new WAVEncoder(),"ssid","password");
AudioBoardStream kit(AudioKitEs8388V1);
// Arduino setup
void setup(){
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Warning);
// start i2s input with default configuration
Serial.println("starting AudioKit...");
auto config = kit.defaultConfig(RX_MODE);
config.input_device = ADC_INPUT_LINE1;
config.sample_rate = 44100;
config.sd_active = false;
kit.begin(config);
Serial.println("AudioKit started");
// start data sink
server.begin(kit, config);
}
// Arduino loop
void loop() {
// Handle new connections
server.doLoop();
}

View File

@@ -0,0 +1,61 @@
/**
* @file streams-effect-server_wav.ino
*
* This sketch uses sound effects applied to a sine wav. The result is provided as WAV stream which can be listened to in a Web Browser
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/Communication/AudioHttp.h"
// WIFI
const char *ssid = "ssid";
const char *password = "password";
AudioWAVServer server(ssid, password);
// Contorl input
float volumeControl = 1.0;
int16_t clipThreashold = 4990;
float fuzzEffectValue = 6.5;
int16_t distortionControl = 4990;
int16_t tremoloDuration = 200;
float tremoloDepth = 0.5;
// Audio
SineWaveGenerator<int16_t> sine;
GeneratedSoundStream<int16_t> stream(sine);
AudioEffectStream effects(stream);
// Audio Format
const int sample_rate = 10000;
const int channels = 1;
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial,AudioLogger::Info);
// setup effects
effects.addEffect(new Boost(volumeControl));
effects.addEffect(new Distortion(clipThreashold));
effects.addEffect(new Fuzz(fuzzEffectValue));
effects.addEffect(new Tremolo(tremoloDuration, tremoloDepth, sample_rate));
// start server
auto config = stream.defaultConfig();
config.channels = channels;
config.sample_rate = sample_rate;
server.begin(effects, config);
sine.begin(config, N_B4);
stream.begin(config);
effects.begin(config);
}
// copy the data
void loop() {
server.copy();
}

View File

@@ -0,0 +1,7 @@
# Using FLITE Speach to Text
I am providing a simple sketch which generates sound data with the Flite text to speach engine.
You need to install https://github.com/pschatzmann/arduino-flite
In this demo we provide the result as WAV stream which can be listened to in a Web Browser

View File

@@ -0,0 +1,37 @@
/**
* @file streams-flite-webserver_wav.ino
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "flite_arduino.h"
#include "AudioTools.h"
#include "AudioTools/Communication/AudioHttp.h"
AudioWAVServer server("ssid","password");
// Callback which provides the audio data
void outputData(Print *out){
Serial.print("providing data...");
Flite flite(*out);
// Setup Audio Info
FliteOutputBase *o = flite.getOutput();
flite.say("Hallo, my name is Alice");
Serial.printf("info %d, %d, %d", o->sampleRate(), o->channels(), o->bitsPerSample());
}
void setup(){
Serial.begin(115200);
server.begin(outputData, 8000,1,16);
}
// Arduino loop
void loop() {
// Handle new connections
server.copy();
}

View File

@@ -0,0 +1,45 @@
/**
* @file streams-generator-server_aac.ino
*
* This sketch generates a test sine wave. The result is provided as AAC stream which can be listened to in a Web Browser
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioCodecs/CodecAACFDK.h"
#include "AudioTools/Communication/AudioHttp.h"
// WIFI
const char *ssid = "ssid";
const char *password = "password";
AudioInfo info(16000,1,16);
AACEncoderFDK fdk;
AudioEncoderServer server(&fdk, ssid, password);
SineWaveGenerator<int16_t> sineWave; // Subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> in(sineWave); // Stream generated from sine wave
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial,AudioLogger::Info);
// configure FDK to use less RAM (not necessary if you activate PSRAM)
fdk.setAudioObjectType(2); // AAC low complexity
fdk.setOutputBufferSize(1024); // decrease output buffer size
fdk.setVariableBitrateMode(2); // low variable bitrate
// start server
server.begin(in, info);
// start generation of sound
sineWave.begin(info, N_B4);
}
// copy the data
void loop() {
server.copy();
}

View File

@@ -0,0 +1,41 @@
/**
* @file streams-generator-webserver_mp3.ino
*
* This sketch generates a test sine wave. The result is provided as mp3 stream which can be listened to in a Web Browser
* Please note that MP3EncoderLAME needs a processor with PSRAM !
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioCodecs/CodecMP3LAME.h"
#include "AudioTools/Communication/AudioHttp.h"
// WIFI
const char *ssid = "ssid";
const char *password = "password";
AudioInfo info(24000, 1, 16);
MP3EncoderLAME mp3;
AudioEncoderServer server(&mp3, ssid, password);
SineWaveGenerator<int16_t> sineWave; // Subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> in(sineWave); // Stream generated from sine wave
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial,AudioLogger::Info);
// start server
server.begin(in, info);
// start generation of sound
sineWave.begin(info, N_B4);
}
// copy the data
void loop() {
server.copy();
}

View File

@@ -0,0 +1,43 @@
/**
* @file streams-generator-server_ogg.ino
*
* This sketch generates a test sine wave. The result is provided as opus ogg
* stream which can be listened to in a Web Browser This seems to be quite
* unreliable in the browser and with ffplay -i http://address it is breaking
* up.
*
* Only saving it to a file for playback seems to help: ffmpeg -i
* http://address test.ogg
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/AudioCodecs/CodecOpusOgg.h"
#include "AudioTools/Communication/AudioHttp.h"
// WIFI
const char *ssid = "ssid";
const char *password = "password";
AudioInfo info(16000, 1, 16);
OpusOggEncoder ogg;
AudioEncoderServer server(&ogg, ssid, password);
SineWaveGenerator<int16_t> sineWave;
GeneratedSoundStream<int16_t> in(sineWave); // Stream generated from sine wave
void setup() {
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// start server
server.begin(in, info);
// start generation of sound
sineWave.begin(info, N_B4);
}
// copy the data
void loop() { server.copy(); }

View File

@@ -0,0 +1,6 @@
# Webserver
With the help of the ESP32 WIFI functionality we can implement a simple web server.
In the example we use a Sine Wave generator as sound source and return the result as an WAV file
It would have been more elegent to use a proper __server library__ - but I did not want to introduce another dependency. So I leave this excercise up to you to implement it with less code by using your preferred library!

View File

@@ -0,0 +1,44 @@
/**
* @file streams-generator-server_wav.ino
*
* This sketch generates a test sine wave. The result is provided as WAV stream which can be listened to in a Web Browser
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/Communication/AudioHttp.h"
// WIFI
const char *ssid = "ssid";
const char *password = "password";
AudioWAVServer server(ssid, password);
// Sound Generation
const int sample_rate = 10000;
const int channels = 1;
SineWaveGenerator<int16_t> sineWave; // Subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> in(sineWave); // Stream generated from sine wave
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial,AudioLogger::Info);
// start server
server.begin(in, sample_rate, channels);
// start generation of sound
sineWave.begin(channels, sample_rate, N_B4);
in.begin();
}
// copy the data
void loop() {
server.copy();
}

View File

@@ -0,0 +1,13 @@
# Webserver
With the help of the ESP32 WIFI functionality we can implement a simple web server.
In the example we use a Sine Wave generator as sound source and return the result as an WAV file
The server can be used like any other output stream and we can use a StreamCopy to provide it with data.
Multiple users can connect to the server!
## Dependencies
- https://github.com/pschatzmann/arduino-audio-tools
- https://github.com/pschatzmann/TinyHttp.git

View File

@@ -0,0 +1,50 @@
/**
* @file streams-generator-server_wav.ino
*
* This sketch generates a test sine wave. The result is provided as WAV stream which can be listened to in a Web Browser
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/Communication/AudioServerEx.h"
// WIFI
const char *ssid = "SSID";
const char *password = "password";
AudioInfo info(10000, 1, 16);
SineWaveGenerator<int16_t> sineWave; // Subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> in(sineWave); // Stream generated from sine wave
AudioWAVServerEx server;
StreamCopy copier(server, in); // copy mic to tfl
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial,AudioLogger::Info);
HttpLogger.setLevel(tinyhttp::Info);
// activate additional checks
copier.setCheckAvailableForWrite(true);
// start server
auto cfg = server.defaultConfig();
cfg.copyFrom(info);
cfg.ssid = ssid;
cfg.password = password;
server.begin(cfg);
// start generation of sound
sineWave.begin(info, N_B4);
in.begin();
}
// copy the data
void loop() {
copier.copy(); // copy data to server
server.copy(); // from server to client
}

View File

@@ -0,0 +1,13 @@
# Webserver
With the help of the ESP32 WIFI functionality we can implement a simple web server.
In the example we use a Sine Wave generator as sound source and return the result as an WAV file
The input is defied as part of the configuration
Multiple users can connect to the server!
## Dependencies
- https://github.com/pschatzmann/arduino-audio-tools
- https://github.com/pschatzmann/TinyHttp.git

View File

@@ -0,0 +1,46 @@
/**
* @file streams-generator-server_wav.ino
*
* This sketch generates a test sine wave. The result is provided as WAV stream which can be listened to in a Web Browser
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/Communication/AudioServerEx.h"
// WIFI
const char *ssid = "SSID";
const char *password = "password";
AudioInfo info(10000, 1, 16);
SineWaveGenerator<int16_t> sineWave; // Subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> in(sineWave); // Stream generated from sine wave
AudioWAVServerEx server;
void setup() {
Serial.begin(115200);
AudioLogger::instance().begin(Serial,AudioLogger::Info);
HttpLogger.setLevel(tinyhttp::Info);
// start server
auto cfg = server.defaultConfig();
cfg.copyFrom(info);
cfg.ssid = ssid;
cfg.password = password;
cfg.input = &in; // Define input
server.begin(cfg);
// start generation of sound
sineWave.begin(info, N_B4);
in.begin();
}
// copy the data
void loop() {
server.copy();
}

View File

@@ -0,0 +1,30 @@
# I2S to Webserver
This sketch reads sound data from I2S. The result is provided as WAV stream which can be listened to in a Web Browser
![INMP441](https://pschatzmann.github.io/Resources/img/inmp441.jpeg)
The INMP441 is a high-performance, low power, digital-output, omnidirectional MEMS microphone with a bottom port. The complete INMP441 solution consists of a MEMS sensor, signal conditioning, an analog-to-digital converter, anti-aliasing filters, power management, and an industry-standard 24-bit I²S interface. The I²S interface allows the INMP441 to connect directly to digital processors, such as DSPs and microcontrollers, without the need for an audio codec in the system.
## Pins
| INMP441 | ESP32
| --------| ---------------
| VDD | 3.3
| GND | GND
| SD | IN (GPIO32)
| L/R | GND
| WS | WS (GPIO15)
| SCK | BCK (GPIO14)
- SCK: Serial data clock for I²S interface
- WS: Select serial data words for the I²S interface
- L/R: Left / right channel selection
When set to low, the microphone emits signals on the left channel of the I²S frame.
When the high level is set, the microphone will send signals on the right channel.
- ExSD: Serial data output of the I²S interface
- VCC: input power 1.8V to 3.3V
- GND: Power groundHigh PSR: -75 dBFS.

View File

@@ -0,0 +1,41 @@
/**
* @file streams-i2s-webserver_wav.ino
*
* This sketch reads sound data from I2S. The result is provided as WAV stream which can be listened to in a Web Browser
*
* @author Phil Schatzmann
* @copyright GPLv3
*/
#include "AudioTools.h"
#include "AudioTools/Communication/AudioHttp.h"
//AudioEncodedServer server(new WAVEncoder(),"ssid","password");
AudioWAVServer server("ssid","password"); // the same a above
I2SStream i2sStream; // Access I2S as stream
ConverterFillLeftAndRight<int16_t> filler(LeftIsEmpty); // fill both channels - or change to RightIsEmpty
void setup(){
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// start i2s input with default configuration
Serial.println("starting I2S...");
auto config = i2sStream.defaultConfig(RX_MODE);
config.i2s_format = I2S_STD_FORMAT; // if quality is bad change to I2S_LSB_FORMAT https://github.com/pschatzmann/arduino-audio-tools/issues/23
config.sample_rate = 22050;
config.channels = 2;
config.bits_per_sample = 16;
i2sStream.begin(config);
Serial.println("I2S started");
// start data sink
server.begin(i2sStream, config, &filler);
}
// Arduino loop
void loop() {
// Handle new connections
server.copy();
}

View File

@@ -0,0 +1,7 @@
# Using SAM Speach to Text
I am providing a simple sketch which generates sound data with the SAM text to speach engine.
You need to install https://github.com/pschatzmann/SAM
In this demo we provide the result as WAV stream which can be listened to in a Web Browser

View File

@@ -0,0 +1,33 @@
/**
* @file streams-sam-webserver_wav.ino
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/Communication/AudioHttp.h"
#include "sam_arduino.h"
AudioWAVServer server("ssid","password");
int channels = 1;
int bits_per_sample = 16;
// Callback which provides the audio data
void outputData(Print *out){
Serial.print("providing data...");
SAM sam(*out, false);
sam.say("hallo, I am SAM");
}
void setup(){
Serial.begin(115200);
// start data sink
server.begin(outputData, SAM::sampleRate(), channels, bits_per_sample);
}
// Arduino loop
void loop() {
// Handle new connections
server.copy();
}

View File

@@ -0,0 +1,7 @@
# Using SAM Speach to Text
I am providing a simple sketch which generates sound data with the TTS text to speach engine.
You need to install https://github.com/pschatzmann/TTS
In this demo we provide the result as WAV stream which can be listened to in a Web Browser

View File

@@ -0,0 +1,34 @@
/**
* @file streams-tts-webserver_wav.ino
*
* @author Phil Schatzmann
* @copyright GPLv3
*
*/
#include "AudioTools.h"
#include "AudioTools/Communication/AudioHttp.h"
#include "TTS.h"
AudioWAVServer server("ssid","password");
// Callback which provides the audio data
void outputData(Print *out){
Serial.print("providing data...");
TTS tts = TTS(*out);
tts.sayText("Hallo, my name is Alice");
}
void setup(){
Serial.begin(115200);
AudioToolsLogger.begin(Serial, AudioToolsLogLevel::Info);
// start data sink
TTSInfo info = TTS::getInfo();
server.begin(outputData, info.sample_rate, info.channels, info.bits_per_sample);
}
// Arduino loop
void loop() {
// Handle new connections
server.copy();
}