마이크로 컨트롤러에는 고품질 '텍스트 to Speech'기능을 제공하기에 충분한 리소스가 없습니다. 그러나 종종 사전 녹음 된 오디오를 기반으로하는 솔루션을 제공하기에 충분할 수 있습니다.
이 접근법의 한계에 대해 궁금해하고 오디오 출력을위한 Arduino 오디오 도구를 기반으로하는 작은 프로토 타입 Arduino 라이브러리를 구현하기로 결정했습니다.
일을 단순하게 유지하기 위해 나는 숫자를 처리 할 수있는 간단한 구현으로 시작했습니다. 따라서 시작점은 숫자를 텍스트로 변환하는 일부 클래스입니다. 그런 다음 텍스트는 사전 녹음 된 오디오 파일을 식별하는 데 사용됩니다.
이 기능은 예를 들어 일부를 빌드하는 데 사용될 수 있습니다
숫자 totext는 숫자 입력을 audio_tools :: 단어의 벡터로 변환합니다. 다음 예에서는 단지 인쇄합니다.
NumberToText ntt;
auto result = ntt.say( 700123.431 );
for ( auto str : result){
Serial. print (str);
Serial. print ( " " );
}
결과는 : 일곱 천 1 백 이십처 도트 4 3 One Zero Zero
시간과 시간을 입력으로 제공해야합니다.
TimeToText ttt;
auto result = ttt.say( 12 , 00 );
for ( auto str : result){
Serial. print (str);
Serial. print ( " " );
}
결과는 정오입니다
해당 단위로 번호를 처리 할 수도 있습니다
NumberUnitToText utt;
auto result = utt.say( 1.01 , " usd " );
for ( auto str : result){
Serial. print (str);
Serial. print ( " " );
}
결과는 1 개의 미국 달러와 1 센트입니다
MP3로 단어를 녹음하면 오디오를 프로그램 메모리에 저장할 수 있기 때문에 별도의 SD 드라이브가 필요할 수도 있습니다. exampleAudiodictionaryValues에는 progmem에 저장된 사전 녹음 된 MP3 파일이 포함되어 있습니다.
# include " SimpleTTS.h "
# include " AudioTools/AudioCodecs/CodecMP3Helix.h "
I2SStream i2s; // audio output via I2S
MP3DecoderHelix mp3; // mp3 decoder
AudioDictionary dictionary (ExampleAudioDictionaryValues);
TextToSpeech tts (i2s, mp3, dictionary);
void setup (){
Serial. begin ( 115200 );
// setup i2s
auto cfg = i2s. defaultConfig ();
cfg. sample_rate = 24000 ;
cfg. channels = 1 ;
i2s. begin (cfg);
tts. say ( " BILLION " );
}
void loop () {
}
"10 억"이라는 단어는 I2S를 통해 사용됩니다.
위에서 설명한 텍스트 생성 클래스를 사용할 수도 있습니다.
# include " SimpleTTS.h "
# include " AudioTools/AudioCodecs/CodecMP3Helix.h "
TimeToText ttt; // Text source
I2SStream i2s; // audio output via I2S
MP3DecoderHelix mp3; // mp3 decoder
AudioDictionary dictionary (ExampleAudioDictionaryValues);
TextToSpeech tts (ttt, i2s, mp3, dictionary);
void setup (){
Serial. begin ( 115200 );
// setup i2s
auto cfg = i2s. defaultConfig ();
cfg. sample_rate = 24000 ;
cfg. channels = 1 ;
i2s. begin (cfg);
ttt. say ( 14 , 40 );
}
void loop () {
}
이것은 i2를 통해 오디오 결과를 출력합니다.
다음은 말하기 시간 및 번호 지원을 제공하고 모든 오디오 파일을 ESP32로 Progmem의 MP3로 저장하는 스케치 정보입니다.
Sketch uses 740438 bytes (23%) of program storage space. Maximum is 3145728 bytes.
Global variables use 23632 bytes (7%) of dynamic memory, leaving 304048 bytes for
나는 이것이 많은 헤드 룸을 떠나고 있다고 생각하며 여전히 SD 드라이브에 오디오를 저장할 수있는 옵션이 있습니다 ...
다음은 생성 된 클래스 문서에 대한 링크입니다. 추가 정보는 Wiki와 내 블로그에서 찾을 수 있습니다.