Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ class FlutterTtsPlugin : MethodCallHandler, FlutterPlugin {

"getLanguages" -> getLanguages(result)
"getVoices" -> getVoices(result)
"getCurrentVoice" -> getCurrentVoice(result)
"getSpeechRateValidRange" -> getSpeechRateValidRange(result)
"getEngines" -> getEngines(result)
"getDefaultEngine" -> getDefaultEngine(result)
Expand Down Expand Up @@ -565,6 +566,23 @@ class FlutterTtsPlugin : MethodCallHandler, FlutterPlugin {
}
}

private fun getCurrentVoice(result: Result) {
try {
val voice = tts!!.voice
if (voice != null) {
val currentVoice = HashMap<String, String>()
readVoiceProperties(currentVoice, voice)
result.success(currentVoice)
} else {
Log.d(tag, "Voice is not set")
result.success(null)
}
} catch (e: NullPointerException) {
Log.d(tag, "getCurrentVoice: " + e.message)
result.success(null)
}
}

private fun getLanguages(result: Result) {
val locales = ArrayList<String>()
try {
Expand Down
8 changes: 8 additions & 0 deletions lib/flutter_tts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,14 @@ class FlutterTts {
final voices = await _channel.invokeMethod('getVoices');
return voices;
}

/// [Future] which invokes the platform specific method for getCurrentVoice
/// Returns a `Hashmap<String, String>` containing a full voice info
/// ***Android supported only***
Future<dynamic> get getCurrentVoice async {
final currentVoice = await _channel.invokeMethod('getCurrentVoice');
return currentVoice;
}

/// [Future] which invokes the platform specific method for isLanguageAvailable
/// Returns `true` or `false`
Expand Down