패키지, 저장소 및 앱 카테고리 검색

GitHub 저장소ixsans/text_to_speech

텍스트에서 음성으로

Flutter 플러그인은 TTS(Text-to-Speech) 서비스를 제공합니다

텍스트에서 음성으로 프로젝트 이미지
스타
19
포크
40
최근 푸시(UTC)
2024. 8. 20.
프로젝트 상태
활성

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

Text To Speech

A Flutter plugin provides TTS (Text-To-Speech) Service. This plugin aims to offer the most of TTS API feature from iOS, Android, web, and macOS.

screenshot.png

Getting Started

To use this plugin, add text_to_speech as a dependency in your pubspec.yaml file:

dependencies:  
  text_to_speech: ^0.2.3

Installation

Android
  • Minimum SDK version: 21
  • Applications targeting SDK 30 (Android 11) need to declare TextToSpeech.Engine.INTENT_ACTION_TTS_SERVICE in the queries elements of Android Manifest (See Android documentation).
<queries>  
  <intent>  
      <action android:name="android.intent.action.TTS_SERVICE" />  
  </intent>  
 </queries>  
iOS & macOS
  • iOS minimum version: 7.0
  • macOs minimum version 10.14

(See Apple documentation).

Features

Feature Android iOS Web macOS
speak :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
stop :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
pause - :white_check_mark: :white_check_mark: :white_check_mark:
resume - :white_check_mark: :white_check_mark: :white_check_mark:
set volume :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
set rate :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
set pitch :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
set language :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
get language :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:
get voice :white_check_mark: :white_check_mark: :white_check_mark: :white_check_mark:

Usages

To start, import the dependency in your code:

import 'package:text_to_speech/text_to_speech.dart';  

Then, create instance of TextToSpeech class:

TextToSpeech tts = TextToSpeech();  

Speak

String text = "Hello, Good Morning!";  
tts.speak(text);  

Set Volume

Volume range: 0-1 where 0 is silence, and 1 is the maximum volume (the default behavior).

double volume = 1.0;  
tts.setVolume(volume);  

Set Rate

Rate range: 0-2.
1.0 is the normal and default speech rate. Lower values slow down the speech (0.5 is half the normal speech rate). Greater values accelerate it (2.0 is twice the normal speech rate).

double rate = 1.0;  
tts.setRate(rate);  

Set Pitch

Pitch range: 0-2.
1.0 is the normal pitch, lower values lower the tone of the synthesized voice, greater values increase it.

double pitch = 1.0;  
tts.setPitch(pitch);  

Set Language

Accepting locale tag name of specific language, e.g. 'en-US'. You can retrieve list of supported language using getLanguage function.

String language = 'en-US';  
tts.setLanguage(language);  

Get Languages

Provide list of supported language codes in locale tag name format, e.g. 'en-US'. You can get display name for specific language code

String language = 'en-US';  
tts.setLanguage(language);  

Get Voice

We can get all available voices or get voices of specific language. This function will returns particular voice name.

List<String> voices = await tts.getVoices();  
  
String language = 'en-US';  
List<String> voices = await tts.getVoiceByLang(language);  

Native API Reference

  • Android TTS API: https://developer.android.com/reference/android/speech/tts/TextToSpeech
  • iOS/macOS AVSpeechSynthesizer API: https://developer.apple.com/documentation/avfaudio/avspeechsynthesizer
  • Web Speech API: https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html#tts-section

Example

You can find example in the example folder and run it to check the implementation.
Move to example directory:

$ cd example  

Run Android / iOS

$ flutter run -d <device_name>  

Run Web

$ flutter run -d chrome  

Run macOS

$ flutter run -d macOS  

TODO

  • [ ] Utterance Status Listener
  • [ ] Linux Implementation
  • [ ] Windows Implementation
ixsans GitHub avatar
GitHub 작성자

ixsans ↗

Passionate Mobile Engineer. Write mobile apps using Java/Kotlin/Swift/Dart.

kataloku.comSurakarta, Indonesia
언어DartKotlinSwiftHTMLRubyObjective-C

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 6 개

  • flutter{"sdk":"flutter"}
  • flutter_web_plugins{"sdk":"flutter"}
  • text_to_speech_macos^0.1.1
  • text_to_speech_platform_interface^0.1.3
  • text_to_speech_web^0.1.2
  • flutter_test개발 의존성{"sdk":"flutter"}

프로젝트에 맞는 저장소를 선택하려면?

사용 목적에 따라 검색하고 개발 활동을 비교한 뒤 원본 저장소에서 요구 사항을 확인하세요.

  1. 이름, 작성자 또는 설명으로 검색하고 기술 주제로 범위를 좁힙니다.
  2. 스타, 포크, 최근 푸시를 함께 비교하세요. 스타는 관심의 지표이며 품질을 보장하지 않습니다.
  3. 사용하기 전에 GitHub에서 README, 라이선스, Issues를 확인하세요.

출처 및 관리

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗