flutter_aiui 0.0.2 copy "flutter_aiui: ^0.0.2" to clipboard
flutter_aiui: ^0.0.2 copied to clipboard

PlatformAndroid

Flutter plugin that allows you to use iFlytek's AIUI on Android.

flutter_aiui #

Flutter plugin that allows you to use iFlytek's AIUI on Android.

Key Features #

  • Speech recognition
  • Semantics understanding
  • Speech synthesis
  • Wakeup

Configuration #

IOS

  • Xcode 7,8 has Bitcode enabled by default, and Bitcode requires support from all class libraries that the project relies on. The AIUI SDK currently does not support Bitcode, and developers need to disable this setting. Simply search for Bitcode in Targets ->Build Settings, find the corresponding option, and set it to NO. As shown in the following figure:
  • Add the following keys to yourInfo.plistfile, located in<project root>/ios/Runner/Info.plist:
<key>NSMicrophoneUsageDescription</key>
<string></string>
<key>NSLocationUsageDescription</key>
<string></string>
<key>NSLocationAlwaysUsageDescription</key>
<string></string>
<key>NSContactsUsageDescription</key>
<string></string>

Android

  • Update your minimum SDK version to 24 in android/app/build.gradle.
android {
    ...
    defaultConfig {
        ...
        minSdkVersion 19 // Change this
        ...
    }
    ...
}
  • Add the following permissions to your AndroidManifest.xml, located in <project root>/android/app/src/main/AndroidManifest.xml

    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    

    Note: To avoid confusion during packaging or generating APK, please add the following code to proguard.cfg:

-dontoptimize
-keep class com.iflytek.**{*;}
-keepattributes Signature
  • Add android:requestLegacyExternalStorage=true of application in AndroidManifest.xml.
<application
        ...
        android:requestLegacyExternalStorage="true">
      ...
</application>      
  • Copy the assets folder from the resources downloaded from iFlytek's AIUI application platform to <project root>/android/app/src/main

Note

Due to the fact that Android 11 no longer allows direct access to sdcard, the resource path in the official configuration file of the Information Technology Branch of the University of Science and Technology will cause the wakeup function to be unusable. Therefore, the current res_path parameter of ivw is dynamically generated, so if you want to use the wakeup function, please remove res_path from the vtn.ini configuration file and the deleted vtn.ini content are as follows:

[auth]
appid=xxxxxx

[cae]
#是否开启降噪功能, 0为不开启,其他为开启,默认为开启
cae_enable = 1
input_audio_unit=2

[ivw]
#是否开启唤醒功能, 0为不开启,其他为开启,默认为不开启
ivw_enable = 1

Usage #

Create agent

To use AIUI functionality, you must first create an AIUI agent.

final AiuiParams _params = AiuiParams(
  appId: appId,
  global: GlobalParams(scene: 'main_box'),
  speech: SpeechParams(wakeupMode: WakeupMode.vtn),
);
await FlutterAiui().initAgent(_params);

Note: To use the wakeup function, simply set the wakeupMode of AiuiParam's speech parameter to WakeupMode.vtn and reinitialize the Agent

Destroy agent

FlutterAiui().destroyAgent();

Add listener

Using a listener to listen for AIUI events

FlutterAiui().addListener(AiuiEventListener(onResult: () => {}));

Remove listener

FlutterAiui().removeListener();

Set parameter

FlutterAiui().setParams(paramsJson);

Start recording

FlutterAiui().startRecordAudio();

Stop recording

FlutterAiui().stopRecordAudio();

Identifying text

FlutterAiui().writeText('xxxxx');

Start tts

FlutterAiui().startTTS('xxxxxx');

End tts

FlutterAiui().stopTTS();

Contribution #

Users are encouraged to become active participants in its continued development — by fixing any bugs that they encounter, or by improving the documentation wherever it’s found to be lacking.

If you wish to make a change,open a Pull Request even if it just contains a draft of the changes you’re planning, or a test that reproduces an issue — and we can discuss it further from there.

License #

MIT


GitHub @cj123195 ·

1
likes
150
points
26
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin that allows you to use iFlytek's AIUI on Android.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_aiui