vais_speech 0.0.6 copy "vais_speech: ^0.0.6" to clipboard
vais_speech: ^0.0.6 copied to clipboard

outdated

A new Flutter plugin.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:toast/toast.dart';
import 'package:vais_speech/model/lyric/lyric.dart';
import 'package:vais_speech/vais_speech.dart';
import 'package:vais_speech_example/record.dart';

void main() {
  VaisSpeech vaisSpeech = VaisSpeech('<YOUR_API_KEY>');

  return runApp(MyApp(vaisSpeech: vaisSpeech));
}

class MyApp extends StatefulWidget {
  final VaisSpeech vaisSpeech;

  const MyApp({Key key, this.vaisSpeech}) : super(key: key);

  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final GlobalKey<NavigatorState> navigatorKey = GlobalKey();

  List<String> _transcript;

  @override
  Widget build(BuildContext context) {
    final mContext = context;
    return MaterialApp(
      navigatorKey: navigatorKey,
      home: Scaffold(
        appBar: AppBar(
          title: const Text('VAIS Speech Demo'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: RaisedButton(
                  child: Text('Offline Record'),
                  onPressed: () {
                    navigatorKey.currentState?.push(MaterialPageRoute(builder: (context) => RecordScreen(
                        vaisSpeech: widget.vaisSpeech,
                        vaisSpeechAudio: widget.vaisSpeech.vaisAudio,
                        isOfflineMode: true)
                    ));
                  },
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: RaisedButton(
                  child: Text('Streaming Record'),
                  onPressed: () {
                    navigatorKey.currentState?.push(MaterialPageRoute(builder: (context) => RecordScreen(
                        vaisSpeech: widget.vaisSpeech,
                        vaisSpeechAudio: widget.vaisSpeech.vaisAudio,
                        isOfflineMode: false)
                    ));
                  }
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: RaisedButton(
                    child: Text('Get Progress'),
                    onPressed: () async {
                      String _audioId = "";
                      if (_audioId.isEmpty) {
                        print("Fill your audio id first");
                        return;
                      }
                      var progress = await widget.vaisSpeech.getProgress(_audioId);
                      print("Your Process now : ${progress.toString()}");
                    }
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: RaisedButton(
                    child: Text('Get Transcript'),
                    onPressed: () async {
                      String _audioId = "";
                      if (_audioId.isEmpty) {
                        print("Fill your audio id first");
                        return;
                      }
                      var transcript = await widget.vaisSpeech.getTranscript(_audioId);
                      setState(() {
                        _transcript = transcript.data.map((item) => "${item.text}\n").toList();
                      });
                    }
                ),
              ),
              Flexible(
                child: Text(_transcript?.toString() ?? ""),
              )
            ],
          ),
        ),
      ),
    );
  }
}
4
likes
0
pub points
15%
popularity

Publisher

unverified uploader

A new Flutter plugin.

Homepage

License

unknown (LICENSE)

Dependencies

byte_array, file, fixnum, flutter, grpc, http, json_annotation, path, protobuf, wakelock, xml

More

Packages that depend on vais_speech