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

outdated

A new Flutter plugin.

VAIS Speech #

Build Status

For easy integration with VAIS Speech service.

Features #

  • Streaming recognition (up to 1 minutes)
  • Offline record audio and recognition (up to 1 hour)

Installation #

Add this to your package's pubspec.yaml file

dependencies:
  vais_speech: [Current version]

How to use? #

VAIS Speech has 2 parts :

  • Record Audio ( Offline and Streaming Support )
  • Uploaded audio following status
  • Get text by speech

Before started

Android :

Set up permission related to record in AndroidManifest.xml, as below

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
iOS :

The same with iOS in Info.plist

	<key>NSAppleMusicUsageDescription</key>
	<string>App need to use music because of retrieving your need uploading file.</string>
	<key>UIBackgroundModes</key>
	<array>
		<string>audio</string>
		<string>fetch</string>
	</array>
Flutter side :

Initialize VAIS instance to use :

final vaisSpeech = VaisSpeech(<YOUR_TOKEN>)

Record Audio:

VAIS Speech have 2 modes to use and you need to decide which mode should be use :

  • Offline mode (default)
  • Streaming mode

  1. Get VAIS Speech Audio and initialize it before recording
final vaisSpeechAudio = vaisSpeech.vaisSpeechAudio; // Get VAIS Speech Audio
await vaisSpeechAudio.init(...) // then initilize it

More about .init() function :

Function Properties
Future init(String path, {AudioFormat audioFormat, int sampleRate = 16000, RecordMode recordMode = RecordMode.Offline}) path : Your recording path - recordMode : Your recording mode

  1. Add Listener to observer your recording. E.g: duration, settings, streaming text (if your are in streaming mode) ...) This method should be call before starting.
vaisSpeechAudio.addListener(listener);
Function Properties
addListener(VaisSpeechCallback listener) see more VaisSpeechCallback
VaisSpeechCallback This callback includes 3 methods : onGeneratedSpeechText / onDurationChanged / onConnectionChanged
  • onGeneratedSpeechText : Fired when there's some texts are translated (Streaming mode only)
  • onConnectionChanged : Fired when the connection with our services is closed (Streaming mode only)
  • onDurationChanged : duration of your recording (for show duration for e.g).

  1. Start Recording : Simply call .start to start recording
    await vaisSpeechAudio.start();

  1. Pause Recording (Offline mode Only) : You will get an Exception when call it in Streaming Mode
    await vaisSpeechAudio.pause();

  1. Resume Recording (Offline mode Only) : You will get an Exception when call it in Streaming Mode
    await vaisSpeechAudio.resume();

  1. Stop Recording :
    await vaisSpeechAudio.stop();

Upload Recorded Audio:

After recording, call .startAsr() to upload your local Audio. This function will return a AudioId

    await vaisSpeechAudio.startAsr(...);
Function Properties
Future path : your located audio file - finalName (optional) your custom audio name

Following status of the Recorded Audio:

    var audioStatus = await vaisSpeechAudio.getProgress(...);
Function Properties
Future audio : your audio id after uploading. This will be return a AudioStatus model
AudioStatus Includes: CREATED, QUEUED, PROCESSING, DONE, ERROR

Get transcript of the Recorded Audio:

    final transcript = await vaisSpeechAudio.getTranscript()..data;
Function Properties
Future audio : your audio id after uploading. This will be return a TranscriptResponse model, you should .data to get a transcript list
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