Skip to content

Commit 82e62af

Browse files
committed
talkie a2dp example
1 parent 36e97c6 commit 82e62af

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* @file streams-talkie-a2dp.ino
3+
* @author Phil Schatzmann
4+
* @copyright GPLv3
5+
* Using TalkiePCM to generate audio to be sent to a Bluetooth Speaker
6+
*/
7+
8+
#include "AudioTools.h"
9+
#include "AudioTools/AudioCodecs/CodecMP3Helix.h"
10+
#include "AudioTools/AudioLibs/A2DPStream.h"
11+
#include "TalkiePCM.h" // https://github.com/pschatzmann/TalkiePCM
12+
#include "Vocab_US_Large.h"
13+
14+
const char* name = "LEXON MINO L"; // Replace with your device name
15+
16+
AudioInfo from(8000, 2, 16); // TTS
17+
AudioInfo to(44100, 2, 16); // A2DP
18+
19+
A2DPStream a2dp;
20+
FormatConverterStream out(a2dp);
21+
BufferedStream bs(1024, out);
22+
TalkiePCM voice(bs, from.channels);
23+
24+
void setup() {
25+
Serial.begin(115200);
26+
AudioLogger::instance().begin(Serial, AudioLogger::Info);
27+
Serial.println("Starting...");
28+
29+
// setup conversion to provide stereo at 44100hz
30+
out.begin(from, to);
31+
32+
// setup a2dp
33+
auto cfg = a2dp.defaultConfig(TX_MODE);
34+
cfg.name = name;
35+
cfg.silence_on_nodata = true; // allow delays with silence
36+
a2dp.begin(cfg);
37+
a2dp.setVolume(0.3);
38+
39+
Serial.println("A2DP Started");
40+
}
41+
42+
void loop() {
43+
voice.say(sp2_DANGER);
44+
voice.say(sp2_DANGER);
45+
voice.say(sp2_RED);
46+
voice.say(sp2_ALERT);
47+
voice.say(sp2_MOTOR);
48+
voice.say(sp2_IS);
49+
voice.say(sp2_ON);
50+
voice.say(sp2_FIRE);
51+
bs.flush();
52+
voice.silence(1000);
53+
}

0 commit comments

Comments
 (0)