diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 9216d94..0d0cd15 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,6 @@ + + UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + NSSpeechRecognitionUsageDescription + To display AR visualisations based on speech input + NSMicrophoneUsageDescription + To detect speech input NSCameraUsageDescription - To capture profile photo please grant camera access + To capture profile photo please grant camera access diff --git a/lib/main.dart b/lib/main.dart index 535ac31..7146420 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,7 +1,9 @@ import 'package:flutter/material.dart'; +import 'package:speech_to_text/speech_to_text.dart' as stt; import 'package:nl2ar/WebObjectsView.dart'; void main() { + WidgetsFlutterBinding.ensureInitialized(); runApp(const MyApp()); } @@ -32,16 +34,42 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - int _counter = 0; + stt.SpeechToText _speech = stt.SpeechToText(); + bool _isListening = false; + String _text = "This is text"; + double _confidence = 1.0; - void _incrementCounter() { - setState(() { - _counter++; - }); + @override + void initState() { + super.initState(); } @override Widget build(BuildContext context) { return WebObjectsView(); } + + void _listen() async { + if (!_isListening) { + bool available = await _speech.initialize( + onStatus: (val) => print('onStatus: $val'), + onError: (val) => print('onError: $val'), + ); + if (available) { + setState(() => _isListening = true); + _speech.listen( + onResult: (val) => setState(() { + _text = val.recognizedWords; + print(_text); + if (val.hasConfidenceRating && val.confidence > 0) { + _confidence = val.confidence; + } + }), + ); + } else { + setState(() => _isListening = false); + _speech.stop(); + } + } + } } diff --git a/pubspec.lock b/pubspec.lock index 05c6095..0a016d6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -45,10 +45,10 @@ packages: dependency: transitive description: name: collection - sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" + sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 url: "https://pub.dev" source: hosted - version: "1.17.1" + version: "1.17.2" crypto: dependency: transitive description: @@ -172,18 +172,18 @@ packages: dependency: transitive description: name: matcher - sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" url: "https://pub.dev" source: hosted - version: "0.12.15" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.2.0" + version: "0.5.0" meta: dependency: transitive description: @@ -200,6 +200,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.8.3" + pedantic: + dependency: transitive + description: + name: pedantic + sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" + url: "https://pub.dev" + source: hosted + version: "1.11.1" permission_handler: dependency: transitive description: @@ -257,10 +265,34 @@ packages: dependency: transitive description: name: source_span - sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" + speech_to_text: + dependency: "direct main" + description: + name: speech_to_text + sha256: "59393a58815a517dc1237a81ccbaf8302f44d107d84fafca9c295cdf7fff404f" + url: "https://pub.dev" + source: hosted + version: "6.3.0" + speech_to_text_macos: + dependency: transitive + description: + name: speech_to_text_macos + sha256: "6b5575e5a8346be1779838b0a482c259474965b5943668830b479147a75b5bfc" + url: "https://pub.dev" + source: hosted + version: "1.0.2" + speech_to_text_platform_interface: + dependency: transitive + description: + name: speech_to_text_platform_interface + sha256: "2ef9c0abf3b4340998fcb489afc4fc8cd7574eff21d912673be59b60ff16850c" + url: "https://pub.dev" + source: hosted + version: "2.1.0" stack_trace: dependency: transitive description: @@ -297,9 +329,11 @@ packages: dependency: transitive description: name: test_api - sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb + sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" url: "https://pub.dev" source: hosted + version: "0.6.0" + vector_math: version: "0.5.1" typed_data: dependency: transitive @@ -325,6 +359,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + web: + dependency: transitive + description: + name: web + sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + url: "https://pub.dev" + source: hosted + version: "0.1.4-beta" sdks: dart: ">=3.0.6 <4.0.0" flutter: ">=2.8.0" diff --git a/pubspec.yaml b/pubspec.yaml index de0aae3..8683048 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -35,6 +35,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + speech_to_text: ^6.3.0 ar_flutter_plugin: ^0.7.3 vector_math: ^2.1.4