azure_speech_recognition 0.0.1 azure_speech_recognition: ^0.0.1 copied to clipboard
An implementation of Azure Speech Recognition Service for Flutter.
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:azure_speech_recognition/azure_speech_recognition.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _centerText = 'Unknown';
@override
void initState() {
super.initState();
}
Future _recognizeVoice() async {
try {
var text = await AzureSpeechRecognition.simpleVoiceRecognition("YOUR SUBSCRIPTION KEY", "YOUR REGION",lang: "en-EN");//await platform.invokeMethod('azureVoice');
/* String newText =
text.substring(text.indexOf('<') + 1, text.length - 2);*/
print("Text: $text");
setState(() {
_centerText = text;
});
} on PlatformException catch (e) {
print("Failed to get text '${e.message}'.");
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Column(
children: <Widget>[
Text('TEXT RECOGNIZED : $_centerText\n'),
FloatingActionButton(onPressed: _recognizeVoice,child: Icon(Icons.mic),),
],
),
),
),
);
}
}