マイクロコントローラーには、高品質の「テキスト」機能を提供するのに十分なリソースがありません。ただし、多くの場合、事前に録音されたオーディオに基づいたソリューションを提供するのに十分な場合があります。
このアプローチの制限について疑問に思っていて、オーディオ出力用のArduinoオーディオツールに基づいた小さなプロトタイプArduinoライブラリを実装することにしました。
物事をシンプルに保つために、私は数字を処理できる簡単な実装とその上に、時間を読み取る別のものから始めました。したがって、出発点は、数字をテキストに変換するいくつかのクラスです。次に、テキストを使用して、事前に録音されたオーディオファイルを識別します。
この機能は、たとえばいくつかを構築するために使用できます
NumberToTextは、番号入力をaudio_tools :: vector of wordsに変換します。次の例では、それらを印刷するだけです。
NumberToText ntt;
auto result = ntt.say( 700123.431 );
for ( auto str : result){
Serial. print (str);
Serial. print ( " " );
}
結果は次のとおりです。
時間を処理するには、時間を入力として提供する必要があります。
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ドライブが必要になることさえ逃げることさえできます。 Exampleaudixictionaryvaluesには、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 () {
}
これにより、i2sを介してオーディオ結果が出力されます。
これは、Talking Time and Number Supportを提供し、すべてのオーディオファイルを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と私のブログにあります