Open monish088 opened 1 month ago
Have you tried the example app on the same devices?
Yes I've tried to implement this application on my android device and Android emulator too
You say "this application". Do you mean the application with the code you listed above?
Have you tried the example application that ships with the plugin?
Yes, i mean the application with the listed code, Whenever I tap on to the Mic button the isListening() method is supposed to work but it isn't working
Can you try the example app that ships with the plugin? The first step in troubleshooting issues like this is to figure out if speech recognition is setup and working properly on the device you are trying to use. Starting with an app that should work is a good way to do that.
The text-to-speech plugin in a Flutter project isn't functioning correctly. Despite implementing it according to documentation, the feature fails to produce speech output on various devices. No specific errors related to text-to-speech are evident in the logs. Assistance is needed to troubleshoot and resolve the issue, possibly involving permissions, compatibility, or platform-specific code.
`import 'package:flutter/material.dart'; import 'package:speech_to_text/speech_recognition_result.dart'; import 'package:speech_to_text/speech_to_text.dart'; import 'package:synthia/feature_box.dart'; import 'package:synthia/pallete.dart';
class HomePage extends StatefulWidget { const HomePage({super.key});
@override State createState() => _HomePageState();
}
class _HomePageState extends State {
final speechTotext = SpeechToText();
String lastWords = '';
@override
void initState() {
super.initState();
initSpeechToText();
}
Future initSpeechToText() async {
await speechTotext.initialize();
setState(() {});
}
Future startListening() async {
await speechTotext.listen(onResult: onSpeechResult);
setState(() {});
}
Future stopListening() async {
await speechTotext.stop();
setState(() {});
}
/// This is the callback that the SpeechToText plugin calls when /// the platform returns recognized words. void onSpeechResult(SpeechRecognitionResult result) { setState(() { lastWords = result.recognizedWords; }); } @override void dispose(){ super.dispose(); speechTotext.stop(); }
@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Synthia'), leading: const Icon(Icons.menu), centerTitle: true, ), body: SingleChildScrollView( child: Column( children: [ Stack( children: [ Center( child: Container( height: 120, width: 120, margin: const EdgeInsets.only(top: 4), decoration: const BoxDecoration( color: Pallete.assistantCircleColor, shape: BoxShape.circle, ), ), ), Container( height: 123, decoration: const BoxDecoration( shape: BoxShape.circle, image: DecorationImage( image: AssetImage('assets/images/virtualAssistant.png'), )), ), ], ), //chat Bubble Container( padding: const EdgeInsets.symmetric( horizontal: 20, vertical: 10, ), margin: const EdgeInsets.symmetric(horizontal: 40).copyWith( top: 30, ), decoration: BoxDecoration( border: Border.all( color: Pallete.borderColor, ), borderRadius: BorderRadius.circular(20).copyWith( topLeft: Radius.zero, ), ), child: const Padding( padding: EdgeInsets.symmetric(vertical: 10), child: Text( 'Good Moring, What task can I do for you?', style: TextStyle( color: Pallete.mainFontColor, fontSize: 25, fontFamily: 'Cera-Pro', ), ), ), ), Container( padding: const EdgeInsets.all(10), alignment: Alignment.centerLeft, margin: const EdgeInsets.only(top: 10, left: 22), child: const Text( 'Here are few features', style: TextStyle( fontFamily: 'Cera-Pro', color: Pallete.mainFontColor, fontSize: 20, fontWeight: FontWeight.bold, ), ), ), //suggestions const Column( children: [ FeatureBox( color: Pallete.firstSuggestionBoxColor, headerText: 'ChatGPT', descriptionText: 'A Smarter way to stay organized and informed with ChatGPT', ), FeatureBox( color: Pallete.secondSuggestionBoxColor, headerText: 'DALL-E', descriptionText: 'Get inspired and stay creative with your personal assistant powered by DALL-E', ), FeatureBox( color: Pallete.thirdSuggestionBoxColor, headerText: 'Smart Voice Assistant', descriptionText: 'Get the best of both worlds with a voice assistant powered by DALL-E and ChatGPT', ), ], ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: () async { if(await speechTotext.hasPermission && speechTotext.isNotListening){ await startListening(); } else if(speechTotext.isListening){ await stopListening(); } else{ initSpeechToText(); } }, child: const Icon(Icons.mic), ), ); } } `