-
-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36e97c6
commit 82e62af
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
examples/examples-tts/streams-talkie-a2dp/streams-talkie-a2dp.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* @file streams-talkie-a2dp.ino | ||
* @author Phil Schatzmann | ||
* @copyright GPLv3 | ||
* Using TalkiePCM to generate audio to be sent to a Bluetooth Speaker | ||
*/ | ||
|
||
#include "AudioTools.h" | ||
#include "AudioTools/AudioCodecs/CodecMP3Helix.h" | ||
#include "AudioTools/AudioLibs/A2DPStream.h" | ||
#include "TalkiePCM.h" // https://github.com/pschatzmann/TalkiePCM | ||
#include "Vocab_US_Large.h" | ||
|
||
const char* name = "LEXON MINO L"; // Replace with your device name | ||
|
||
AudioInfo from(8000, 2, 16); // TTS | ||
AudioInfo to(44100, 2, 16); // A2DP | ||
|
||
A2DPStream a2dp; | ||
FormatConverterStream out(a2dp); | ||
BufferedStream bs(1024, out); | ||
TalkiePCM voice(bs, from.channels); | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
AudioLogger::instance().begin(Serial, AudioLogger::Info); | ||
Serial.println("Starting..."); | ||
|
||
// setup conversion to provide stereo at 44100hz | ||
out.begin(from, to); | ||
|
||
// setup a2dp | ||
auto cfg = a2dp.defaultConfig(TX_MODE); | ||
cfg.name = name; | ||
cfg.silence_on_nodata = true; // allow delays with silence | ||
a2dp.begin(cfg); | ||
a2dp.setVolume(0.3); | ||
|
||
Serial.println("A2DP Started"); | ||
} | ||
|
||
void loop() { | ||
voice.say(sp2_DANGER); | ||
voice.say(sp2_DANGER); | ||
voice.say(sp2_RED); | ||
voice.say(sp2_ALERT); | ||
voice.say(sp2_MOTOR); | ||
voice.say(sp2_IS); | ||
voice.say(sp2_ON); | ||
voice.say(sp2_FIRE); | ||
bs.flush(); | ||
voice.silence(1000); | ||
} |