• Stars
    star
    210
  • Rank 187,585 (Top 4 %)
  • Language
    C++
  • License
    GNU General Publi...
  • Created almost 6 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Refurbished Arduino version of the Talkie library from Peter Knight.

Talkie

Speech library for Arduino

Badge License: GPLv3     Badge Version     Badge Commits since latest     Badge Build Status     Badge Hit Counter

Stand With Ukraine

Available as Arduino library "Talkie".

Button Install     Button Changelog


The original version can be found [here](https://github.com/going-digital/Talkie).
A good explanation of the TMS5220 operation and the LPC frame format can be found [here](https://github.com/mamedev/mame/blob/master/src/devices/sound/tms5220.txt).

YouTube Videos

Demonstration of Talkie voltmeter example Intoduction by Gadget Reboot
Demonstration of Talkie voltmeter example Intoduction by Gadget Reboot

Improvements to the original and to the non blocking version of PaulStoffregen

  • Improved code so Talkie now runs on 8 MHz Arduino (with millis() interrupt disabled while talking).
  • Fixed the ISR_RATIO Bug for plain Arduino.
  • Added utility functions sayQNumber(), sayQFloat(), sayQVoltageMilliVolts() extracted from the examples.
  • Inverted output at pin 11 is enabled by default to increase volume for direct attached piezo or speaker.
  • Added comments and did refactoring to better understand the functionality.
  • Added compatibility to Arduino Tone library by stopping timer1 interrupts at every end of speech.
  • Extracted initializeHardware() and terminateHardware() functions for easy adapting to other platforms.
  • Currently supporting:
    • ATmega328 as found on the Uno and Nano boards.
    • ATmega2560 as found on the MEGA 2560 board.
    • ATmega32U4 as found on the Leonardo and CircuitPlaygound boards.
    • ARM M0 (Tested for Arduino Zero) as found on the SAMD, Teensy and Particle boards.
    • ESP32. ESP8266 is theoretical possible using FRC2, but for now Arduino shares the FRC1 timer between interrupts and PWM.
    • ARM M3 (Tested for BluePill) for Roger Clarks as well as STM core.

Pin and timer mapping table for different platforms

Platform Pin normal Pin inverted 8kHz timer PWM timer Remarks
AVR (Uno and Nano) Pin 3 Pin 11 timer1 timer2
ATmega2560 Pin 6/PH3 Pin 7/PH4 timer1 timer4
Leonardo Pin 9/PB5 Pin 10/PB6 timer1 timer4
ProMicro Pin 5/PC6 % timer1 timer4
Esplora Pin 6/PD7 % timer1 timer4
Zero (SAMD) A0 % TC5 DAC0
ESP32 Pin 25 % hw_timer_t DAC0
BluePill Pin 3 % timer3 analogWrite Roger Clarks core
BluePill PA3 % timer4 analogWrite STM core
Teensy Pin 12/14721 % IntervalTimer analogWrite

Timer usage

Timer 1 (Servo timer) is used at all ATmegas for updating voice output data at 8 kHz.
Timer 2 (Tone timer) on ATmega328 (62500 Hz / 16 µs) or Timer 4 on ATmega2560 + ATmega32U4 (5 µs) is used to generate the 8 bit PWM output.
Both timers are therefore not available for other libraries / purposes, like servo control or tone output.

Differences between BluePill cores

There are two cores for the BluePill.

Generation of the high speed PWM is complicated for Roger Clark core and easy for the STM core. Program size for VoltmeterSayQ.cpp is 21 kByte for Roger Clark core and 32 kByte for STM core. The 8 kHz interrupt handling requires 8 µs for Roger Clark core and 12 µs for STM core.


Hints

  • As default both inverted and not inverted outputs are enabled to increase volume if speaker is attached between them.
  • The library uses Timer 1 and Timer 2 on ATmega328, so libraries like Tone, Servo, analogWrite(), and some other libraries cannot be used while speaking.
  • After a call to say...() you can use tone() again.
  • using [Sloeber]ervo write() after a call to say... you must detach() and attach() the servo before first write() in order to initialize the timer again for Servo.
  • If you want to use SPI functions on ATmega328 while Talkie is speaking, then disable Talkies usage of pin 11 by Talkie Voice(true, false); instead of Talkie Voice; or Voice.doNotUseInvertedOutput();.
  • Porting to ATtinys is not possible, since they lack the hardware multiplication. ( Believe me, I tried it! )
  • I use the speakers from old earphones or headphones, which have approximately 16 to 32 Ω, directly without a series resistor on my ATmegas. The headphone speaker tend to be much louder, especially when they stay in their original housings. If you do not connect the speaker between non inverted and inverted output, you must use a series capacitor of 1 to 10 uF do block the DC current. Look for the right polarity. The AC current is proportional to the rectance of the speaker, not its resistance in Ω, and it is between 10 and 40 mA. The latter is definitely out of specification for ATmegas but quite loud -what you hear is what you supply- and running for hours on my desk. If you are not sure, just use a piezo speaker or a power amplifier.

Predefined vocabulary

The predefined vocabulary can be found in the Vocab_*.h files, especially in Vocab_US_Large.h.

Own vocabulary

To create LPC data you can use the python_wizard like described here or the BlueWizard for Mac OS X.

Another way to create LPC data is to use Qboxpro, an unsupported old Windows application running under XP, which can produce Talkie compatible data streams. The missing BWCC.DLL (Borland Windows Custom Control Library) can be found e.g. here. The process is described here and goes like this:

  • Create a new project using the following project parameters : byte / 8 KHz / 5220 coding table
  • Goto Project and add the audio file
  • Choose process using : medium bit rate and pressing OK
  • Edit concatenation : insert concatenation after by adding a name; then insert phrase and press OK
  • Format it by choosing the first line in the format menu : LPC 10V, 4UV

OUTPUT FILTER

    C to avoid clicks  Low pass 1600Hz  DC decoupling (optional)
                      _____
  D3 >------||-------| 10k |---+----------||-------> to Power amplifier
           100nF      -----    |         10nF
                              ---
                              --- 10 nF
                               |
                               |
                               _ GND

Compile options / macros for this library

To customize the software to different requirements, there are some compile options / macros available.
Modify them by enabling / disabling them, or change the values if applicable.

Name Default value File Description
NO_COMPATIBILITY_FOR_TONE_LIB_REQUIRED disabled Talkie.h If you do not use the Arduino Tone library, then activating can save up to 844 bytes program size.
FAST_8BIT_MODE disabled Talkie.h If defined we use 8bit instead of 16 bit coefficients K1 and K2. This saves 10 microseconds (40 instead of 50 us) for a 16 MHz ATmega and has almost the same quality, except of a few "dropouts" e.g. in the word "thousand".

Changing include (*.h) files with Arduino IDE

First, use Sketch > Show Sketch Folder (Ctrl+K).
If you have not yet saved the example as your own sketch, then you are instantly in the right library folder.
Otherwise you have to navigate to the parallel libraries folder and select the library you want to access.
In both cases the library source and include files are located in the libraries src directory.
The modification must be renewed for each new library version!

Modifying compile options / macros with PlatformIO

If you are using PlatformIO, you can define the macros in the platformio.ini file with build_flags = -D MACRO_NAME or build_flags = -D MACRO_NAME=macroValue.

Modifying compile options / macros with Sloeber IDE

If you are using Sloeber as your IDE, you can easily define global symbols with Properties > Arduino > CompileOptions.
Sloeber settings

Schematic for voltmeter example

Fritzing schematic for voltmeter example

Revision History

Version 1.3.2

  • Fixed ESP32 timer bug.

Version 1.3.1

  • Updated _1_Voltmeter example and renamed example names.
  • Improved SAMD support.

Version 1.3.0

  • Removed blocking wait for ATmega32U4 Serial in examples.
  • 10 bit Coefficients are working now, but they do not sound better 😞.
  • Tested on an ESP32.
  • Tested on a BluePill.

Version 1.2.0

  • Corrected wrong function name doNotUseUseInvertedOutput().
  • Added functions digitalWriteNonInvertedOutput() and digitalWriteInvertedOutput().

Version 1.1.0

  • SAMD support.
  • ESP32 support.
  • Teensy support.
  • Version number.
  • Renamed *.c to *.cpp files.
  • Added function sayQTimeout() in TalkieUtils.cpp.
  • Added example USDistanceToVoice.
  • Added function sayQVoltageVolts().
  • Improved end handling to minimize clicks.

Version 1.0.2

  • ATmega2560 supported and tested
  • Always set pins to input when finishing, to avoid a click.

Version 1.0.1

  • Added SPI compatibility by not resetting pin 11 to input if SPI is detected
  • Added new constructor Talkie(bool aUseNonInvertedOutputPin, bool aUseInvertedOutputPin);

Version 1.0.0

  • Initial Arduino library version

CI

The library examples are tested with GitHub Actions for the following boards:

  • arduino:avr:uno
  • arduino:avr:leonardo
  • arduino:avr:mega
  • arduino:sam:arduino_due_x
  • esp8266:esp8266:huzzah:eesz=4M3M,xtal=80
  • esp32:esp32:featheresp32:FlashFreq=80
  • STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8

Requests for modifications / extensions

Please write me a PM including your motivation/problem if you need a modification or an extension.

If you find this library useful, please give it a star.

More Repositories

1

ServoEasing

Arduino library to enable smooth servo movement.
C++
305
star
2

DigistumpArduino

Improved version of Digistump avr core for Arduino
C
196
star
3

Smart-Battery-Module-Info_For_Arduino

Arduino sketch, which helps detecting the connections of the I2C interface and prints info available from the SMB (SmartBatteryModule) laptop battery pack.
C++
111
star
4

micronucleus-firmware

Fork for the firmware / digispark part of the micronucleus repository
C
76
star
5

NeoPatterns

Patterns for NeoPixel strips and matrixes including the patterns of the NeoPattern Example by Adafruit.
C++
67
star
6

ATtinySerialOut

Minimal bit-bang send serial 38400/115200 baud for 1MHz or 115200/230400 baud for 8 or 16MHz ATtiny clock
C++
63
star
7

JK-BMSToPylontechCAN

Converts the JK-BMS RS485 data to Pylontech CAN data
C++
60
star
8

Arduino-BlueDisplay

Arduino library for the BlueDisplay App. The App converts your smartphone into an Android remote touch display.
C++
45
star
9

arduino-test-compile

Github Action to compile all examples of an Arduino library for one board and check for errors
Shell
41
star
10

PWMMotorControl

Arduino library to control brushed DC motors by PWM. Uses optional attached encoders to drive fixed distances.
C++
40
star
11

Arduino-FrequencyDetector

Fast audio frequency detector without fft for plain Arduino and Attiny85. Whistle switch example included.
C++
39
star
12

Ultimate-Battery-Tester

The ultimate battery tester with ESR measurement and discharge graph. Based on an Arduino Nano and a 1602 LCD.
C++
38
star
13

digitalWriteFast

Arduino library for faster and smaller digitalWrite(), digitalRead() and pinMode() functions using direct port manipulation for constant pin numbers.
C
24
star
14

ATtiny-HighVoltageProgrammer_FuseEraser

Using an Arduino and 12 Volt to erase wrong ATtiny fuse settings by High-voltage Serial Programming
C++
21
star
15

PlayRtttl

Arduino library to play RTTTL melodies / ringtones non blocking from FLASH or RAM.
C++
19
star
16

STMF3-Discovery-Demos

Apps for a STMF3-Discovery board with HY32D touch screen or BlueDisplay App - DSO, FrequenySynthesizer, Accelerometer and DAC demo etc.
C++
19
star
17

SoftStart

Generates TRIAC control pulse for soft start of motors used in circular saw and other DIY tools.
C++
17
star
18

Arduino-RobotCar

Enables autonomous driving of a 2 or 4 wheel car with an Arduino and a Adafruit Motor Shield V2. To avoid obstacles a HC-SR04 Ultrasonic sensor mounted on a SG90 Servo continuously scans the area. Manual control is by a GUI implemented with a Bluetooth HC-05 Module and the BlueDisplay library.
C++
16
star
19

Arduino-Utils

Utility collection for Arduino programming
C++
14
star
20

LCDBigNumbers

Arduino library to write big numbers on a 1602 or 2004 LCD.
C++
14
star
21

Arduino-Simple-DSO

Simple DSO software based on standard Arduino boards, a HC-05 and the BlueDisplay library.
C++
11
star
22

Arduino-OpenWindowAlarm

Issues an alarm, if window is open for more than 5 minutes. Arduino sketch for ATtiny85. Battery operated (6 microAmpere).
C++
11
star
23

android-blue-display

The App receives basic draw and GUI requests from Arduino etc. over Bluetooth (HC-05) and renders it. It also sends touch events over Bluetooth back to Arduino.
Java
10
star
24

EasyButtonAtInt01

Arduino library for push buttons at INT0 and / or INT1 pin (pin 2 / 3). Provides debouncing and toggle button functionality.
C++
10
star
25

ESP32-Cam-Sewer-inspection-car

Tiny and cheap robot car for inspecting sewer pipes >= 125 mm. With pan servo for the ESP32-Cam module
C++
8
star
26

LightweightServo

Lightweight Servo library for Arduino for 2 Servos at Pin 9 and 10. Needs only timer1, no interrupts or other resources.
C++
7
star
27

Arduino-DTSU666H_PowerMeter

Arduino Nano substitute for a RS485 3 Phase DTSU666-H coil based power meter. Less resolution, but better display
C++
7
star
28

OpenledRace

OpenLedRace version with accelerator or button inputs, track animations and winner melody
C++
5
star
29

SimpleTouchScreenDSO

Simple DSO Software for Arduino Uno/MEGA with a Touchscreen Shield
C++
4
star
30

iButtonProgrammer

Arduino UNO / Nano iButton reader as well as programmer for writable iButtons of type RW1990
C++
4
star
31

QuadrupedControl

Arduino Library for controlling a mePed robot V2 with 8 servos using an IR remote.
C++
4
star
32

SloeberTutorial

Tutorial for the Sloeber Eclipse plugin
Batchfile
3
star
33

github.io

GitHub pages for my projects
2
star
34

Arduino-Lessons-for-School

Arduino lessons for the Arduino course at the Gymnasium for 15 year old pupils (grade 8+9)
C++
2
star
35

Github-Actions

Github actions script for testing build of Arduino libraries with arduino-test-compile
C++
2
star
36

android-SystemSoundDemo

App to show and play all tones from android.media.ToneGenerator.
Java
1
star
37

RobotArmControl

Program for controlling a MeArm / RobotArm with 4 servos using 4 potentiometers and/or an IR remote
C++
1
star
38

AvrTracing

The last hope for the desperate AVR programmer. A small (344 bytes) Arduino library to have real program traces and to find the place where your program hangs
C
1
star