搜尋套件、儲存庫與 APP 分類

套件詳情v1.0.3

flutter_tts_improved

Flutter_TTS 插件的分叉版本,同時在 Android 和 iOS 上使用 Utterance API 的進度報告器。

近 30 天下載
43
喜歡數
21
Pub 分數
40

安裝套件

flutter pub add flutter_tts_improved

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Flutter_TTS_Improved 是原始 Flutter_TTS 插件的分支,透過在 Android 與 iOS 上整合 Utterance API 的進度報告,增強了語音合成功能。它讓開發者能夠即時追蹤語音合成進度,改善語音驅動應用的使用者體驗。此套件維持與原始版本的相容性,同時為每個語句提供細緻的回饋,例如開始、結束與錯誤事件。非常適合需要精確時間控制的互動式語音助理、有聲書或輔助工具。

適用情境

  • 即時語音進度追蹤
  • 應用中的無障礙功能
  • 互動式語音助理
  • 有聲讀物播放
  • 教育類語言學習應用

主要特色

  • 透過 Utterance API 進行進度報告
  • 跨平台支援(Android 與 iOS)
  • 即時事件回調
  • 對語音合成的增強控制
  • 與 Flutter_TTS 兼容

適合對象

  • 開發語音功能應用的開發者
  • 需要精確語音時間的應用
  • 注重可訪問性的應用程式
  • 互動式教程和學習工具

使用建議

  • 需要原生平台設定
  • 僅限支援語音合成 API 的平台
  • 某些設備可能需要額外的權限
  • 取決於底層作業系統語音引擎的穩定性

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Flutter Text To Speech Improved

The flutter_tts plugin (https://github.com/dlutton/flutter_tts) is GREAT! Thanks @dlutton for all your hard work on getting it up and running. Now it is time to improve it by allowing for the Utterances API to report the 'progress' of the speech of the Utterance. This is relatively new for Android, only introduced in Android 26. It has been around on iOS for quite some time though, back around iOS 7.0.

My goal with this plugin is to allow everyone in flutter to track where the speech is currently at. This can be used to print words on the screen as they are spoken, highlight words of a paragraph as they are uttered, for timing how long each word takes to say at a given speed, or really any other weird reason you may need it. This API is powerful, and I know people are asking for it, and there is simply not a plugin yet that covers it. Surprise! Now there is. You are welcome.

Features

  • [x] Android & iOS
    • [x] speak
    • [x] stop
    • [x] get languages
    • [x] set language
    • [x] is language available
    • [x] set speech rate
    • [x] set speech volume
    • [x] set speech pitch
    • [x] get voices
    • [x] set voice
    • [x] #NEW track what word is currently being said (on all iOS 7+ and Android 26+)
  • [x] Android
    • [x] set Silence

Usage

Android

Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.

minSdkVersion 21

iOS

There's a known issue with integrating plugins that use Swift into a Flutter project created with the Objective-C template. Flutter#16049

Example

To use this plugin :

  dependencies:
    flutter:
      sdk: flutter
    flutter_tts_improved:
  • instantiate a FlutterTtsImproved instance
FlutterTtsImproved tts = new FlutterTtsImproved();
speak, stop, getLanguages, setLanguage, setSpeechRate, setVolume, setPitch, isLanguageAvailable
Future _speak() async{
    var result = await tts.speak("Hello World");
    if (result == 1) setState(() => ttsState = TtsState.playing);
}

Future _stop() async{
    var result = await tts.stop();
    if (result == 1) setState(() => ttsState = TtsState.stopped);
}

List<dynamic> languages = await tts.getLanguages;

await tts.setLanguage("en-US");

await tts.setSpeechRate(1.0);

await tts.setVolume(1.0);

await tts.setPitch(1.0);

await tts.isLanguageAvailable("en-US");
Listening for platform calls
// #NEW
tts.setProgressHandler((String fullPhrase, int wordOffset, int endOfWordOffset, String currentWord) {
  setState(() {
    _wordToDisplay = currentWord;
  });
});

tts.setStartHandler(() {
  setState(() {
    ttsState = TtsState.playing;
  });
});

tts.setCompletionHandler(() {
  setState(() {
    ttsState = TtsState.stopped;
  });
});

tts.setErrorHandler((msg) {
  setState(() {
    ttsState = TtsState.stopped;
  });
});

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。