text-to-speech through DAC to audio amp/speaker

Dependencies:   mbed

text-to-speech TTS

Committer:
manitou
Date:
Sat Jun 24 19:41:42 2017 +0000
Revision:
3:d12c34704b6d
Parent:
0:bcd16e4a0207
format/indent

Who changed what in which revision?

UserRevisionLine numberNew contents of line
manitou 0:bcd16e4a0207 1 /**
manitou 0:bcd16e4a0207 2 * Text To Speech synthesis library
manitou 0:bcd16e4a0207 3 * Copyright (c) 2008 Clive Webster. All rights reserved.
manitou 0:bcd16e4a0207 4 *
manitou 0:bcd16e4a0207 5 * Nov. 29th 2009 - Modified to work with Arduino by Gabriel Petrut:
manitou 0:bcd16e4a0207 6 * The Text To Speech library uses Timer1 to generate the PWM
manitou 0:bcd16e4a0207 7 * output on digital pin 10. The output signal needs to be fed
manitou 0:bcd16e4a0207 8 * to an RC filter then through an amplifier to the speaker.
manitou 0:bcd16e4a0207 9 * http://www.tehnorama.ro/minieric-modulul-de-control-si-sinteza-vocala/
manitou 0:bcd16e4a0207 10 *
manitou 0:bcd16e4a0207 11 * Modified to allow use of different PWM pins by Stephen Crane.
manitou 0:bcd16e4a0207 12 */
manitou 0:bcd16e4a0207 13
manitou 0:bcd16e4a0207 14 #ifndef TTS_h
manitou 0:bcd16e4a0207 15 #define TTS_h
manitou 0:bcd16e4a0207 16
manitou 0:bcd16e4a0207 17 #include "mbed.h"
manitou 0:bcd16e4a0207 18 #include "english.h"
manitou 0:bcd16e4a0207 19
manitou 0:bcd16e4a0207 20 #define byte uint8_t
manitou 0:bcd16e4a0207 21
manitou 0:bcd16e4a0207 22 // DAC pins assume 8-bit DAC
manitou 0:bcd16e4a0207 23 #ifdef TARGET_K64F
manitou 0:bcd16e4a0207 24 #define DACpin DAC0_OUT
manitou 0:bcd16e4a0207 25 #endif
manitou 0:bcd16e4a0207 26
manitou 0:bcd16e4a0207 27 #ifdef TARGET_NUCLEO_F446RE
manitou 0:bcd16e4a0207 28 #define DACpin A2
manitou 0:bcd16e4a0207 29 #endif
manitou 0:bcd16e4a0207 30
manitou 0:bcd16e4a0207 31 #ifdef TARGET_DISCO_F469NI
manitou 0:bcd16e4a0207 32 #define DACpin A5
manitou 0:bcd16e4a0207 33
manitou 0:bcd16e4a0207 34 #endif
manitou 0:bcd16e4a0207 35
manitou 0:bcd16e4a0207 36 #ifdef TARGET_ARCH_MAX
manitou 0:bcd16e4a0207 37 #define DACpin PA_4
manitou 0:bcd16e4a0207 38 #define DACmax 4096
manitou 0:bcd16e4a0207 39 #endif
manitou 0:bcd16e4a0207 40
manitou 0:bcd16e4a0207 41 #ifdef TARGET_LPC1768
manitou 0:bcd16e4a0207 42 #define DACpin p18
manitou 0:bcd16e4a0207 43 #endif
manitou 0:bcd16e4a0207 44
manitou 0:bcd16e4a0207 45 #ifdef TARGET_DISCO_L476VG
manitou 0:bcd16e4a0207 46 #define DACpin PA_5
manitou 0:bcd16e4a0207 47 #endif
manitou 0:bcd16e4a0207 48
manitou 0:bcd16e4a0207 49
manitou 0:bcd16e4a0207 50
manitou 0:bcd16e4a0207 51 class TTS {
manitou 0:bcd16e4a0207 52 public:
manitou 0:bcd16e4a0207 53 /**
manitou 0:bcd16e4a0207 54 * constructs a new text-to-speech
manitou 0:bcd16e4a0207 55 * pin is the PWM pin on which audio is output
manitou 0:bcd16e4a0207 56 * (valid values: 9, 10, 3)
manitou 0:bcd16e4a0207 57 */
manitou 0:bcd16e4a0207 58 TTS(void);
manitou 0:bcd16e4a0207 59
manitou 0:bcd16e4a0207 60 /**
manitou 0:bcd16e4a0207 61 * speaks a string of (english) text
manitou 0:bcd16e4a0207 62 */
manitou 0:bcd16e4a0207 63 void sayText(const char *text);
manitou 0:bcd16e4a0207 64
manitou 0:bcd16e4a0207 65 /**
manitou 0:bcd16e4a0207 66 * speaks a string of phonemes
manitou 0:bcd16e4a0207 67 */
manitou 0:bcd16e4a0207 68 void sayPhonemes(const char *phonemes);
manitou 0:bcd16e4a0207 69
manitou 0:bcd16e4a0207 70 /**
manitou 0:bcd16e4a0207 71 * sets the pitch; higher values: lower pitch
manitou 0:bcd16e4a0207 72 */
manitou 0:bcd16e4a0207 73 void setPitch(byte pitch);
manitou 0:bcd16e4a0207 74
manitou 0:bcd16e4a0207 75 /**
manitou 0:bcd16e4a0207 76 * gets the pitch
manitou 0:bcd16e4a0207 77 */
manitou 0:bcd16e4a0207 78 byte getPitch(void);
manitou 0:bcd16e4a0207 79 };
manitou 0:bcd16e4a0207 80
manitou 0:bcd16e4a0207 81 #endif