alan_voice 1.2.2 copy "alan_voice: ^1.2.2" to clipboard
alan_voice: ^1.2.2 copied to clipboard

outdated

Alan voice plugin. One can easily add voice interaction to exisiting app with this plugin See more on the homepage and in the docs section - https://alan.app/docs/intro.html

example/lib/main.dart

import 'package:alan_voice/alan_voice.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class AlanStartButton extends StatefulWidget {

  @override
  State<StatefulWidget> createState() {
    return new AlanButtonState();
  }
}

class AlanButtonState extends State<AlanStartButton> {
  String _platformVersion = 'Unknown';
  bool _enabled = true;

  void _initAlanButton() async {
    AlanVoice.addConnectionCallback((str) => debugPrint("Connection state callback. New state is $str"));
    AlanVoice.initButton("8e0b083e795c924d64635bba9c3571f42e956eca572e1d8b807a3e2338fdd0dc/stage");

    String platformVersion;

    try {
      platformVersion = await AlanVoice.version;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    _testCall();

    setState(() {
      _platformVersion = platformVersion;
      _enabled = false;
    });
  }

  void _testCall() async {
    try {
      var res = await AlanVoice.call("script::test", "{\"x\":\"Hey!\"}");
      print (res);
    } on Exception catch (e){
      print(e.toString());
    }
  }

  @override
  Widget build(BuildContext context) {
    return new Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text('Running on: $_platformVersion\n'),
          RaisedButton(
            key: new Key("start_btn"),
            color: Colors.blueAccent,
            onPressed: _enabled ? _initAlanButton : null,
            textColor: Colors.white,
            child: const Text("START"),
          ),
        ]);
  }
}

class _MyAppState extends State<MyApp> {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Alan voice plugin example'),
        ),
        body: Center(
            child: new AlanStartButton()
        ),
      ),
    );
  }

}
114
likes
0
points
496
downloads

Publisher

unverified uploader

Weekly Downloads

Alan voice plugin. One can easily add voice interaction to exisiting app with this plugin See more on the homepage and in the docs section - https://alan.app/docs/intro.html

Homepage

License

unknown (license)

Dependencies

flutter, package_info

More

Packages that depend on alan_voice