nativescript-azure-cognitiveservices
azure-cognitiveservices NativeScript 插件。
npm i --save nativescript-azure-cognitiveservices

npm npm

nativescript-azure-cognitiveservices

Azure 认知服务 NativeScript 实现。支持 iOS 和 Android 平台。

特性

  • 语音转文本
  • 文本转语音
  • WAV 录音器

注意:当您使用此服务时,界面将保持阻塞,直到返回任何结果。我建议使用 NativeScript Worker Loader 在后台运行服务

安装

tns plugin add nativescript-azure-cognitiveservices

用法(请查看示例项目以获取详细信息)

导入

JavaScript

var azure = require("nativescript-azure-cognitiveservices");
var azureService = new azure.AzureCognitiveservices("API_KEY", "Region");

TS

import { AzureCognitiveservices, SpeechSynthesisResult, SpeechToTextResult } from "nativescript-azure-cognitiveservices";

constructor() {
this.azureService = new AzureCognitiveservices("API_KEY", "Region");
}

函数

speechSynthesis(contents: any, voiceName?: string): any;
speechToTextRecognizeOnce(audioFile?: string, recognitionLanguage?: string): any;
startContinuousRecognition(recognitionLanguage?: string): any;
stopContinuousRecognition(): void;
startRecorder(fileName?: string): void;
stopRecorder(): any;
audioDataSaveAsMP3(audioData: any, fileName?: string): Promise<string>;

需要权限

Android

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

iOS

<key>NSMicrophoneUsageDescription</key>
<string>Recording Practice Sessions</string>