csdcorp / speech_to_text

A Flutter plugin that exposes device specific text to speech recognition capability.
BSD 3-Clause "New" or "Revised" License
348 stars 217 forks source link

The method 'SpeechToTextMacOS.listen' has fewer named arguments than those of overridden method 'SpeechToTextPlatform.listen'. #477

Closed ninajlu closed 2 months ago

ninajlu commented 3 months ago

Error (Xcode): ../../../.pub-cache/hosted/pub.dev/speech_to_text_macos-1.0.2/lib/speech_to_text_macos.dart:93:16: Error: The method 'SpeechToTextMacOS.listen' has fewer named arguments than those of overridden method 'SpeechToTextPlatform.listen'. I get an error when compiling for iOS. I don't need the MacOS STT functionality but it's breaking the iOS compile.

whobick commented 3 months ago

Getting a similar issue here. No changes made and was working up until today.

Launching lib/main.dart on Web Server in debug mode... Waiting for connection from debug service on Web Server...
/home/.pub-cache/hosted/pub.dev/speech_to_text-6.5.1/lib/speech_to_text_web.dart:143:16: Error: The method 'SpeechToTextPlugin.listen' has fewer named arguments than those of overridden method 'SpeechToTextPlatform.listen'. Future listen( ^ /home/.pub-cache/hosted/pub.dev/speech_to_text_platform_interface-2.2.0/lib/speech_to_text_platform_interface.dart:215:16: Context: This is the overridden method ('listen'). Future listen( ^ /home/.pub-cache/hosted/pub.dev/speech_to_text-6.5.1/lib/speech_to_text_web.dart:143:16: Error: The method 'SpeechToTextPlugin.listen' doesn't have the named parameter 'options' of overridden method 'SpeechToTextPlatform.listen'. Future listen( ^ /home/.pub-cache/hosted/pub.dev/speech_to_text_platform_interface-2.2.0/lib/speech_to_text_platform_interface.dart:215:16: Context: This is the overridden method ('listen'). Future listen( ^ Waiting for connection from debug service on Web Server... 63.5s Failed to compile application.

sowens-csd commented 3 months ago

Well that's surprising, my fault, sorry. I'm updating the platform interface for an upcoming version of STT but I didn't think anyone would get the new version without having an updated STT available. What's your pubspec.yaml dependency look like?

whobick commented 3 months ago

Well that's surprising, my fault, sorry. I'm updating the platform interface for an upcoming version of STT but I didn't think anyone would get the new version without having an updated STT available. What's your pubspec.yaml dependency look like?

My pubspec.yaml is as follows:

name: test_app description: A new Flutter project.

environment: sdk: ">=3.0.0 <4.0.0"

dependencies: flutter: sdk: flutter algoliasearch: ^0.2.0+2 aligned_dialog: 0.0.6 auto_size_text: 3.0.0 cached_network_image: 3.2.1 carousel_slider: 4.2.1 cloud_firestore: 4.13.1 cloud_firestore_platform_interface: 6.0.5 cloud_firestore_web: 3.8.5 cloud_functions: 4.5.8 cloud_functions_platform_interface: 5.5.11 cloud_functions_web: 4.6.11 collection: 1.17.2 dropdown_button2: 2.3.9 easy_debounce: 2.0.1 emoji_flag_converter: 1.1.0 equatable: 2.0.5 file_picker: 6.1.1 firebase_analytics: 10.7.4 firebase_analytics_platform_interface: 3.8.4 firebase_analytics_web: 0.5.5+11 firebase_auth: 4.15.2 firebase_auth_platform_interface: 7.0.8 firebase_auth_web: 5.8.11 firebase_core: 2.24.2 firebase_core_platform_interface: 5.0.0 firebase_core_web: 2.10.0 firebase_dynamic_links: 5.4.8 firebase_dynamic_links_platform_interface: 0.2.6+16 firebase_messaging: 14.7.8 firebase_messaging_platform_interface: 4.5.17 firebase_messaging_web: 3.5.17 firebase_performance: 0.9.3+8 firebase_performance_platform_interface: 0.1.4+16 firebase_performance_web: 0.1.4+16 flutter_animate: 4.1.1+1 flutter_cache_manager: 3.3.1 flutter_native_splash: 2.3.1 flutter_plugin_android_lifecycle: 2.0.17 flutter_staggered_grid_view: 0.7.0 font_awesome_flutter: 10.6.0 from_css_color: 2.0.0 go_router: 7.1.1 google_fonts: 4.0.3 google_sign_in: 6.1.5 google_sign_in_android: 6.1.20 google_sign_in_ios: 5.6.4 google_sign_in_platform_interface: 2.4.2 google_sign_in_web: 0.12.1 image_picker: 1.0.4 image_picker_android: 0.8.8 image_picker_for_web: 3.0.1 image_picker_ios: 0.8.8+2 image_picker_platform_interface: 2.9.1 intl: 0.18.1 json_path: 0.6.2 mime_type: 1.0.0 page_transition: 2.1.0 path_provider: 2.0.14 path_provider_android: 2.0.25 path_provider_foundation: 2.2.2 path_provider_platform_interface: 2.0.6 permission_handler: 10.0.0 pin_code_fields: 8.0.1 plugin_platform_interface: 2.1.6 provider: 6.0.5 rxdart: 0.27.7 shared_preferences: 2.2.2 shared_preferences_android: 2.2.1 shared_preferences_foundation: 2.3.4 shared_preferences_platform_interface: 2.3.1 shared_preferences_web: 2.2.1 sign_in_with_apple: 4.3.0 sign_in_with_apple_platform_interface: 1.0.0 sign_in_with_apple_web: 1.0.1 speech_to_text: ^6.5.1 sqflite: 2.2.6 stream_transform: 2.1.0 table_calendar: 3.0.9 text_search: 1.0.1 timeago: 3.2.2 universal_io: 2.2.2 url_launcher: 6.1.10 url_launcher_android: 6.0.27 url_launcher_ios: 6.1.4 url_launcher_platform_interface: 2.1.2 video_player: 2.8.1 video_player_android: 2.4.10 video_player_avfoundation: 2.5.1 video_player_platform_interface: 6.2.1 video_player_web: 2.1.2 webview_flutter: 4.0.5 webview_flutter_android: 3.3.1 webview_flutter_platform_interface: 2.0.2 webview_flutter_wkwebview: 3.1.1 webviewx_plus: 0.3.3 xml: 6.3.0 youtube_player_iframe: git: url: https://github.com/FlutterFlow/youtube_player_flutter.git path: packages/youtube_player_iframe

dev_dependencies: flutter_launcher_icons: 0.13.1 flutter_lints: 3.0.0 image: 4.0.17 lints: 3.0.0

flutter_test: sdk: flutter

flutter: uses-material-design: true assets:

sowens-csd commented 3 months ago

Can you try the 6.5.0 version and see if it is affected?

sowens-csd commented 3 months ago

Also, 6.6.0-dev is now uploaded. This uses the newest platform interface but isn't quite a released version yet.

MyTechAgent commented 3 months ago

ahh getting the same issue. Seems to be an issue with the newly added options field, but it's across all packages. 6.6.0 didn't work.

whobick commented 3 months ago

@MyTechAgent Check your syntax when updating. Tried with 6.6.0-dev and it seemed to work with the following setup:

import 'package:speech_to_text/speech_recognition_error.dart'; import 'package:speech_to_text/speech_recognition_result.dart'; import 'package:speech_to_text/speech_to_text.dart';

Future startTextRecording() async { bool _onDevice = false; final TextEditingController _pauseForController = TextEditingController(text: '3'); final TextEditingController _listenForController = TextEditingController(text: '30'); double minSoundLevel = 50000; double maxSoundLevel = -50000; String _currentLocaleId = ''; final SpeechToText speech = SpeechToText();

final options = SpeechListenOptions( onDevice: _onDevice, listenMode: ListenMode.dictation, cancelOnError: false, partialResults: true, autoPunctuation: true, enableHapticFeedback: true);

bool isInitialized = await speech.initialize(onError: (error) { speech.stop(); print('Error!: $error'); });

if (isInitialized && speech.isNotListening) { print('starting text recording');

var systemLocale = await speech.systemLocale();
_currentLocaleId = systemLocale?.localeId ?? '';
final pauseFor = int.tryParse(_pauseForController.text);
final listenFor = int.tryParse(_listenForController.text);

speech.listen(
  onResult: (result) {
    [your update here]
    });
  },
  listenFor: Duration(seconds: listenFor ?? 30),
  pauseFor: Duration(seconds: pauseFor ?? 3),
  listenOptions: options,
  localeId: _currentLocaleId,
  onSoundLevelChange: (level) {
    minSoundLevel = min(minSoundLevel, level);
    maxSoundLevel = max(maxSoundLevel, level);
    level = level;
  },
);

} }

MyTechAgent commented 3 months ago

you are an absolute legend. Thank you sir. That fixed the issue.

sowens-csd commented 3 months ago

I tested this morning by creating a new project with 6.5.1 and it builds and runs without problem. I built on both iOS and Mac OS. I don't understand how the confusion happened.

It seems, based on the errors you posted, that the 6.5.1 version is/was using a newer version of the platform interface and failing to build, but I now can't find the problem. Is anyone still seeing the same behaviour with 6.5.1? If so did you try running flutter clean in the project then a flutter pub get?

sk92129 commented 3 months ago

I see this problem when we try to build for web: flutter build web

MyTechAgent commented 3 months ago

Afternoon all, It’s an issue with the audio package that is being used. I have split out mobile and web for the time being until the vendor can fix the issue. I am using audio_player for the mobile and using a different audio package for the web. 

Sent from Yahoo Mail for iPhone

On Tuesday, January 30, 2024, 2:59 am, Sean K @.***> wrote:

I see this problem when we try to build for web: flutter build web

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

sowens-csd commented 3 months ago

I've just pushed 6.6.0 which should fix the issue. If anyone has a chance to try it please let me know.