環境構築
Expo の標準ライブラリであるexpo-speechライブラリを使ってみたいだけなので、Managed Workflowでblankを選択します。
% expo init speech-sandbox ? Choose a template: expo-template-blank Using Yarn to install packages. You can pass --npm to use npm instead. Extracting project files... Customizing project... Initialized a git repository. Installing dependencies... ・ ・ ・ success Saved lockfile. ✨ Done in 23.73s. Your project is ready at /Users/takayasugiyama/speech-sandbox To get started, you can type: cd speech-sandbox yarn start
試す
今回お目当てのライブラリ expo-speechをインストールします。
% expo install expo-speech
UsageのコードをApp.jsに貼り付けて使ってみます。
以下のようになればセットアップは OK です。

音量を上げた状態でPress to hear some wordsを押すと、0と呼ばれます。
- 値をいじってみる
今度は、thingToSayという変数の値を0からthis is a test of text to speechに変更してみます。そうすると変数に代入した値が音声で読み上げられます。
- 日本語を出力してみる
そのままオプションを付けずにthingToSayにこれは音声読み上げのテストですと代入しても読み上げられません。しかし、オプションにオブジェクトに{ language: "ja" }を渡すと日本語でthingToSayの値を読み上げてくれます。
Speech.speak(thingToSay, { language: "ja" });
感想
音声読み上げもライブラリがあったんだと感動しました。