wluper_plugin_flutter

Creator: coderz1093

Last updated:

0 purchases

wluper_plugin_flutter Image
wluper_plugin_flutter Images

Languages

Categories

Add to Cart

Description:

wluper plugin flutter

Wluper Plugin #
Getting Started #

Add the package in dev_dependencies.

dev_dependencies:
wluper_plugin_flutter: ^1.1.0
copied to clipboard

Import the plugin in main.dart or where you need.

import 'package:wluper_plugin_flutter/wluper_plugin_flutter.dart';
import 'package:wluper_plugin_flutter/wluper_plugin_interface.dart';
copied to clipboard

Implement WluperPluginInterface protocol in the class where you want manipulate the parsed tree.

class _MyAppState extends State<MyApp> implements WluperPluginInterface {
...
copied to clipboard

Override the methods of the WluperPluginInterface to handle Errors, live text and end of speech event.

@override
void wluperOnError(String error){
// implement here your code
}

@override
void wluperOnLiveText(String text){
// implement here your code
}

@override
void wluperEndOfSpeech(){
// implement here your code
}
copied to clipboard

Declare WluperPluginFlutter object.

class _MyAppState extends State<MyApp> implements WluperPluginInterface {
...
WluperPluginFlutter wluperSDK = WluperPluginFlutter();
...
copied to clipboard

Initialise the SDK with the tu_api_key, log_api_key, client_id and the WluperPluginInterface listener.

Future<void> initPlatformState() async {
...
wluperSDK.init(this, _client_id, _tu_api_key, _log_api_key ).then((result) => /*implement here your code*/ );
...
copied to clipboard

Wrap plugin methods wluperSDK.startListening(), wluperSDK.understand() and wluperSDK.understand().

class _MyAppState extends State<MyApp> implements WluperPluginInterface {
...

void startListening(){
wluperSDK.startListening().then((result) => /*implement here your code*/);
}

void understand(text){
wluperSDK.understand(text).then((result) => /*implement here your code*/);
}

void cancelListening(){
wluperSDK.cancelListening().then((result) => setState(() => /*implement here your code*/);
}

...
copied to clipboard

Invoke the methods startListening(), understand(text) and cancelListening() from UI. While you speak, the live text is received by the listener wluperOnLiveText . The end of speech is detected automatically by the SDK and it is notified in the wluperEndOfSpeech callback (see point 4).

class _MyAppState extends State<MyApp> implements WluperPluginInterface{
String _status = 'Unknown';
String _tree = "";
String _error = "";
String _plain_text ="";
...
void cleanUI(){
setState(() {
_status = "";
_error= "";
_tree = "";
_plain_text = "";
});
}
...
children: <Widget>[
Text('SDK STATUS', style: TextStyle(fontWeight: FontWeight.bold)),
Text(_status),
Row(
children: <Widget>[
TextButton(style: TextButton.styleFrom( textStyle: const TextStyle(fontSize: 20)),
onPressed: () { cleanUI(); startListening(); },
child: const Text('Listen')),
TextButton( style: TextButton.styleFrom(textStyle: const TextStyle(fontSize: 20)),
onPressed: () { cancelListening();},
child: const Text('Cancel'))
],
),
Text('ASR OUTPUT', style: TextStyle(fontWeight: FontWeight.bold)),
TextField( controller: textController,
maxLines: 3,
decoration: const InputDecoration( border: OutlineInputBorder(),
hintText: 'Enter a sentence to understand')),
TextButton( style: TextButton.styleFrom( textStyle: const TextStyle(fontSize: 20)),
onPressed: () { understand(textController.text); },
child: const Text('Understand')),
Text('BODY RESPONSE', style: TextStyle(fontWeight: FontWeight.bold)),
Text(_tree),
Text('ERROR', style: TextStyle(fontWeight: FontWeight.bold)),
Text(_error),
])
...
copied to clipboard

Permissions

Android
Add below permission to the AndroidManifest.xml
<uses-permission android:name="android.permission.RECORD_AUDIO" />
copied to clipboard
iOS
Add below permissions to info.plist
<key>NSMicrophoneUsageDescription</key>
<string>Audio is recorded and transcribed.</string>
<key>NSSpeechRecognitionUsageDescription</key>
<string>We need to record your voice.</string>
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.