This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Expo 语音
一个提供文本转语音功能访问的库。
expo-speech 提供了一个 API,可让你在应用中使用文本转语音功能。
在 iOS 真机设备上,如果设备处于静音模式,
expo-speech将不会发出声音。请确保已关闭静音模式。
安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
API
import * as Speech from 'expo-speech';
Constants
Type: number
Maximum possible text length acceptable by Speech.speak() method. It is platform-dependent.
On iOS, this returns Number.MAX_VALUE.
Methods
Determine whether the Text-to-speech utility is currently speaking. Will return true if speaker
is paused.
Promise<boolean>Returns a Promise that fulfils with a boolean, true if speaking, false if not.
Pauses current speech. This method is not available on Android.
Promise<void>Resumes speaking previously paused speech or does nothing if there's none. This method is not available on Android.
Promise<void>Speak out loud the text given options. Calling this when another text is being spoken adds an utterance to queue.
voidInterrupts current speech and deletes all in queue.
Promise<void>