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);
FunctionProperties
addListener(VaisSpeechCallback listener)see more VaisSpeechCallback
VaisSpeechCallbackThis 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(...);
FunctionProperties
Future startAsr(String path, {String finalName = ''})path : your located audio file - finalName (optional) your custom audio name

Following status of the Recorded Audio:

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

Get transcript of the Recorded Audio:

    final transcript = await vaisSpeechAudio.getTranscript()..data;
FunctionProperties
Future getTranscript(String audioId)audio : your audio id after uploading. This will be return a TranscriptResponse model, you should .data to get a transcript list

Libraries

audio
audio_response
base_response
cloud_speech.pb
cloud_speech.pbenum
cloud_speech.pbgrpc
cloud_speech.pbjson
created_audio_response
lyric
lyric_response
network
offline_controller
page_response
signature
signature_response
status
streaming_controller
vais_helper
vais_speech
vais_speech
vais_speech_audio