
React本地插件使用Spokestack添加语音。这包括语音识别,唤醒和自然语言理解,以及使用Spokestack声音将文本综合为语音。
使用NPM:
npm install --save react-native-spokestack或使用纱线:
yarn add react-native-spokestack然后按照每个平台的说明将React-Native-Spokestack链接到您的项目:
首先,打开XCode并转到项目 - >信息以将iOS部署目标设置为13.0或更高。
另外,将部署设置为目标 - >一般 - >部署信息下的13.0。
当引入Flipper进行反应本地时,设置了一些库搜索路径以供Swift。 React Native Project中的默认搜索路径存在很长的问题,因为Swift 5.0添加了搜索路径,该搜索路径阻止了仅在Swift 5.2或更高版本中使用API的任何其他React本机库。 spokestack-ios,反应本地spokestack的依赖性使用这些API和Xcode将无法构建。
幸运的是,修复程序非常简单。转到您的目标 - >构建设置并搜索“库搜索路径”。
从列表中删除""$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)"" 。
在运行pod install之前,请确保进行以下编辑。
React-Native-Spokestack使用仅在iOS 13+中可用的相对较新的API。将部署目标设置为iOS 13的顶部:
platform :ios , '13.0'我们还需要使用use_frameworks!在我们的podfile中,以支持用迅速编写的依赖项。
target 'SpokestackExample' do
use_frameworks!
#...目前, use_frameworks!不与Flipper一起使用,因此我们还需要禁用Flipper。卸下豆荚纤维中的任何与脚钳相关的线条。在React Native 0.63.2+中,它们看起来像这样:
# X Remove or comment out these lines X
# use_flipper!
# post_install do |installer|
# flipper_post_install(installer)
# end
# XX React Native 0.64.0使用use_frameworks!在他们的豆荚里。
有关此错误的更多信息,请参见Facebook/React-Native#31149。
要解决此问题,请将以下内容添加到您的podfile:
# Moves 'Generate Specs' build_phase to be first for FBReactNativeSpec
post_install do | installer |
installer . pods_project . targets . each do | target |
if ( target . name &. eql? ( 'FBReactNativeSpec' ) )
target . build_phases . each do | build_phase |
if ( build_phase . respond_to? ( :name ) && build_phase . name . eql? ( '[CP-User] Generate Specs' ) )
target . build_phases . move ( build_phase , 0 )
end
end
end
end
end 删除您现有的podfile.lock和pods文件夹,以确保没有冲突,然后安装吊舱:
$ npx pod-install将以下内容添加到您的info.plist中以启用权限。
< key >NSMicrophoneUsageDescription</ key >
< string >This app uses the microphone to hear voice commands</ string >
< key >NSSpeechRecognitionUsageDescription</ key >
< string >This app uses speech recognition to process voice commands</ string >弗里普(Flipper)致力于修复其pod for use_frameworks! ,我们必须禁用脚钳。我们已经从上面的豆荚中删除了脚依依赖,但是在appdelegate.m中仍然有一些代码导入flipper。有两种解决此问题的方法。
-DFB_SONARKIT_ENABLED=1 。在我们的示例应用程序中,我们完成了选项1,并保留在Flipper代码中,以便将来使其在将来工作,并且可以添加回去。
# import < AVFoundation/AVFoundation.h > 设置AudioSession类别。有几种可行的配置。
以下是适合大多数用例的建议:
- ( BOOL )application:(UIApplication *)application didFinishLaunchingWithOptions:( NSDictionary *)launchOptions
{
AVAudioSession *session = [AVAudioSession sharedInstance ];
[session setCategory: AVAudioSessionCategoryPlayAndRecord
mode: AVAudioSessionModeDefault
options: AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionAllowAirPlay | AVAudioSessionCategoryOptionAllowBluetoothA2DP | AVAudioSessionCategoryOptionAllowBluetooth
error: nil ];
[session setActive: YES error: nil ];
// ... 该示例使用使用系统提供的ASRS( AndroidSpeechRecognizer和AppleSpeechRecognizer )。但是,100%的设备无法使用AndroidSpeechRecognizer 。如果您的应用程序支持没有内置语音识别的设备,请使用配置文件道具将配置profile设置为Spokestack配置文件,以使用profile ASR。
有关更多信息,请参见我们的ASR文档。
// ...
ext {
// Set the minimum SDK to 24.
// React Native 0.64+ sets version 21.
// If you prefer to leave the minimum SDK at 21,
// another option is to set this to 21, but
// also set android.enableDexingArtifactTransform=false
// in your top-level gradle.properties.
// See https://github.com/google/ExoPlayer/issues/6801#issuecomment-574089568
minSdkVersion = 24
// ...
dependencies {
// Minimium gradle is 3.0.1+
// The latest React Native already has this
classpath( " com.android.tools.build:gradle:4.2.1 " )将必要的权限添加到您的AndroidManifest.xml 。第一个权限通常已经存在。使用麦克风需要第二个。
<!-- For TTS -->
< uses-permission android : name = " android.permission.INTERNET " />
<!-- For wakeword and ASR -->
< uses-permission android : name = " android.permission.RECORD_AUDIO " />
<!-- For ensuring no downloads happen over cellular, unless forced -->
< uses-permission android : name = " android.permission.ACCESS_NETWORK_STATE " />Record_audio的权限很特别,因为它必须在AndroidManifest.xml中列出,并在运行时要求。有几种方法可以处理此操作(React-Native-Spokestack并不为您做到这一点):
虽然iOS将自动启动权限对话框,但您必须在Android中手动执行此操作。
React Native已经为此提供了一个模块。有关更多信息,请参见React React Native的Persissimensionsandroid。
开始使用Spokestack,或在ASR,NLU和TTS上查看我们的深入教程。另外,请务必查看食谱以解决常见问题的快速解决方案。
example/文件夹中包含一个工作示例应用程序。
import Spokestack from 'react-native-spokestack'
import { View , Button , Text } from 'react-native'
function App ( ) {
const [ listening , setListening ] = useState ( false )
const onActivate = ( ) => setListening ( true )
const onDeactivate = ( ) => setListening ( false )
const onRecognize = ( { transcript } ) => console . log ( transcript )
useEffect ( ( ) => {
Spokestack . addEventListener ( 'activate' , onActivate )
Spokestack . addEventListener ( 'deactivate' , onDeactivate )
Spokestack . addEventListener ( 'recognize' , onRecognize )
Spokestack . initialize (
process . env . SPOKESTACK_CLIENT_ID ,
process . env . SPOKESTACK_CLIENT_SECRET
)
// This example starts the Spokestack pipeline immediately,
// but it could be delayed until after onboarding or other
// conditions have been met.
. then ( Spokestack . start )
return ( ) => {
Spokestack . removeAllListeners ( )
}
} , [ ] )
return (
< View >
< Button onClick = { ( ) => Spokestack . activate ( ) } title = "Listen" />
< Text > { listening ? 'Listening...' : 'Idle' } </ Text >
</ View >
)
} 要在您的应用中将模型文件包括在本地(而不是从CDN下载),您还需要添加必要的扩展名,以便Babel可以包含这些文件。为此,请编辑您的metro.config.js 。
const defaults = require ( 'metro-config/src/defaults/defaults' )
module . exports = {
resolver : {
assetExts : defaults . assetExts . concat ( [ 'tflite' , 'txt' , 'sjson' ] )
}
}然后使用源对象包括模型文件:
Spokestack . initialize ( clientId , clientSecret , {
wakeword : {
filter : require ( './filter.tflite' ) ,
detect : require ( './detect.tflite' ) ,
encode : require ( './encode.tflite' )
} ,
nlu : {
model : require ( './nlu.tflite' ) ,
vocab : require ( './vocab.txt' ) ,
// Be sure not to use "json" here.
// We use a different extension (.sjson) so that the file is not
// immediately parsed as json and instead
// passes a require source object to Spokestack.
// The special extension is only necessary for local files.
metadata : require ( './metadata.sjson' )
}
} )这不是必需的。将远程URL传递到相同的配置选项,并且首次调用initialize时将下载和缓存文件。
请参阅了解如何为存储库和开发工作流程贡献的贡献指南。
▸初始化( clientId , clientSecret , config? ): Promise void
初始化语音管道;所有其他方法都需要。
前2个ARGS是您的Spokestack凭据免费提供的https://spokestack.io。避免在您的应用中进行硬编码。有几种方法可以在代码中包含环境变量。
使用process.env:https://babeljs.io/docs/en/babel-plugin-transform-inline-enline-envorirnment-variables/
使用git忽略的本地.env文件:https://github.com/goatandsheep/react-native-dotenv https://github.com/luggit/react-native-config
有关所有可用选项,请参见SpokestackConfig。
example
import Spokestack from 'react-native-spokestack'
// ...
await Spokestack . initialize ( process . env . CLIENT_ID , process . env . CLIENT_SECRET , {
pipeline : {
profile : Spokestack . PipelineProfile . PTT_NATIVE_ASR
}
} ) | 姓名 | 类型 |
|---|---|
clientId | string |
clientSecret | string |
config? | [SpokestackConfig](#SpokestackConfig) |
Promise void
index.ts:64
▸销毁(): Promise void
破坏语音管道,删除所有听众,并释放所有资源。这可以在重新定位管道之前调用。一个打电话的好地方是在componentWillUnmount中。
example
componentWillUnmount ( ) {
Spokestack . destroy ( )
} Promise void
index.ts:81
▸start (): Promise void
开始语音管道。语音管道从deactivate状态开始。
example
import Spokestack from 'react-native-spokestack`
// ...
Spokestack . initialize ( process . env . CLIENT_ID , process . env . CLIENT_SECRET )
. then ( Spokestack . start ) Promise void
index.ts:96
▸停止(): Promise void
停止语音管道。这有效地停止了ASR,VAD和WAVEWORD。
example
import Spokestack from 'react-native-spokestack`
// ...
await Spokestack . stop ( ) Promise void
index.ts:110
▸激活(): Promise void
手动激活语音管道。使用PTT配置文件时,这是必要的。 VAD配置文件也可以激活ASR,而无需调用此方法。
example
import Spokestack from 'react-native-spokestack`
// ...
< Button title = "Listen" onClick = { ( ) => Spokestack . activate ( ) } /> Promise void
index.ts:126
▸停用(): Promise void
停用语音管道。如果配置文件包含WakeWord,则管道将返回聆听whookword。如果VAD处于活动状态,则管道可以在不调用激活()的情况下重新激活。
example
import Spokestack from 'react-native-spokestack`
// ...
< Button title = "Stop listening" onClick = { ( ) => Spokestack . deactivate ( ) } /> Promise void
index.ts:142
▸综合( input , format? , voice? ): Promise string
将一些文本综合为语音返回Promise<string> ,字符串是可播放MPEG的URL。
目前只有一个免费的声音可用(“演示 - 男性”)。如果您使用Spokestack Maker帐户创建了自定义语音,则可以更改语音。请参阅https://spokestack.io/pricing#maker。
example
const url = await Spokestack . synthesize ( 'Hello world' )
play ( url ) | 姓名 | 类型 |
|---|---|
input | string |
format? | [TTSFormat](#TTSFormat) |
voice? | string |
Promise < string >
index.ts:158
▸说话( input , format? , voice? ): Promise void
将一些文本综合为语音,然后立即通过默认音频系统播放音频。音频会话的处理可能会变得非常复杂,我们建议使用专注于音频的RN库,而不是非常简单的播放。
目前只有一个免费的声音可用(“演示 - 男性”)。
example
await Spokestack . speak ( 'Hello world' ) | 姓名 | 类型 |
|---|---|
input | string |
format? | [TTSFormat](#TTSFormat) |
voice? | string |
Promise void
index.ts:174
▸分类( utterance ): Promise SpokestackNLUResult
使用意图/插槽自然语言理解模型将话语分类为spokestack.initialize()。有关更多信息,请参见https://www.spokestack.io/docs/concepts/nlu。
example
const result = await Spokestack . classify ( 'hello' )
// Here's what the result might look like,
// depending on the NLU model
console . log ( result . intent ) // launch | 姓名 | 类型 |
|---|---|
utterance | string |
Promise SpokestackNLUResult
index.ts:190
▸isInitialized (): Promise boolean
返回Spokestack是否已初始化
example
console . log ( `isInitialized: ${ await Spokestack . isInitialized ( ) } ` ) Promise boolean
index.ts:199
▸iSstarted (): Promise boolean
返回语音管道是否已经开始
example
console . log ( `isStarted: ${ await Spokestack . isStarted ( ) } ` ) Promise boolean
index.ts:208
▸ISActivated (): Promise boolean
返回语音管道当前是否已激活
example
console . log ( `isActivated: ${ await Spokestack . isActivated ( ) } ` ) Promise boolean
index.ts:217
•信心: number
从0到1代表NLU模型对其意图的置信度的数字,其中1代表绝对置信度。
types.ts:115
•意图: string
基于NLU模型提供的匹配的意图
types.ts:113
•插槽: SpokestackNLUSlots
与意图相关的数据,由NLU模型提供
types.ts:117
▪[键: string ]: SpokestackNLUSlot
• RAWVALUE : string
用户话语中识别的插槽的原始字符串值
types.ts:104
•类型: string
插槽的类型,如模型元数据所定义
types.ts:100
•价值: any
用户话语中识别的插槽的解析(键入)值
types.ts:102
▸addeventListener ( eventType , listener , context? ): EmitterSubscription
绑定到本机库发出的任何事件,请参见所有可用事件列表的事件。
example
useEffect ( ( ) => {
const listener = Spokestack . addEventListener ( 'recognize' , onRecognize )
// Unsubsribe by calling remove when components are unmounted
return ( ) => {
listener . remove ( )
}
} , [ ] ) | 姓名 | 类型 | 描述 |
|---|---|---|
eventType | string | 我们注册听众的活动的名称 |
listener | ( event : any )=> void | 侦听器功能 |
context? | Object | 听众的背景 |
EmitterSubscription
index.ts:237
▸emoveEventListener ( eventType , listener ): void
删除活动听众
example
Spokestack . removeEventListener ( 'recognize' , onRecognize ) | 姓名 | 类型 | 描述 |
|---|---|---|
eventType | string | 活动的名称发射 |
listener | (... args : any [])= any | 发出指定事件时要调用的功能 |
void
index.ts:253
▸removeAlllisteners (): void
删除任何现有的听众
example
Spokestack . removeAllListeners ( ) void
index.ts:265
使用Spokestack TTS时,支持三种格式。原始文本,SSML和语音标记。请参阅https://www.speechmarkdown.org/如果不熟悉语音宣传。使用SSML或语音标记时,预计IPA。
• SpeechmarkDown = 2
types.ts:73
• SSML = 1
types.ts:72
•文字= 0
types.ts:71
使用addEventListener() , removeEventListener()和removeAllListeners()添加和删除事件处理程序。 iOS和Android都可以使用所有事件。
| 姓名 | 数据 | 描述 |
|---|---|---|
| 认出 | { transcript: string } | 每当能够成功完成语音识别时,就被解雇。 |
| partial_recognize | { transcript: string } | 每当笔录在语音识别过程中变化时被解雇。 |
| 开始 | null | 当语音管道开始时被解雇(开始聆听WakeWord或启动VAD)。 |
| 停止 | null | 当语音管道停止时被解雇。 |
| 激活 | null | 当语音管道通过VAD,WakeWord或调用.activate()激活时,被解雇。 |
| 停用 | null | 当语音管道停用时被解雇。 |
| 玩 | { playing: boolean } | 当TTS播放启动和停止时被解雇。请参阅speak()函数。 |
| 暂停 | null | 由于缺乏识别,当主动管道时间熄灭时被解雇。 |
| 痕迹 | { message: string } | 发射跟踪消息。冗长由traceLevel选项确定。 |
| 错误 | { error: string } | 当Spokestack发生错误时被解雇。 |
当触发错误事件时,任何现有承诺将被拒绝。
这些是可以传递给Spokestack.initialize(_, _, spokestackConfig)的配置选项。 SpokestackConfig中无需选项。
SpokestackConfig具有以下结构:
interface SpokestackConfig {
/**
* This option is only used when remote URLs are passed to fields such as `wakeword.filter`.
*
* Set this to true to allow downloading models over cellular.
* Note that `Spokestack.initialize()` will still reject the promise if
* models need to be downloaded but there is no network at all.
*
* Ideally, the app will include network handling itself and
* inform the user about file downloads.
*
* Default: false
*/
allowCellularDownloads ?: boolean
/**
* Wakeword, Keyword, and NLU model files are cached internally.
* Set this to true whenever a model is changed
* during development to refresh the internal model cache.
*
* This affects models passed with `require()` as well
* as models downloaded from remote URLs.
*
* Default: true in dev mode, false otherwise
*
* **Important:** By default, apps in production will
* cache models to avoid downloading them every time
* the app is launched. The side-effect of this optimization
* is that if models change on the CDN, apps will
* not pick up those changes–unless the app were reinstalled.
* We think this is a fair trade-off, but set this to `true`
* if you prefer to download the models every time the app
* is launched.
*/
refreshModels ?: boolean
/**
* This controls the log level for the underlying native
* iOS and Android libraries.
* Also add a `"trace"` event listener to get trace events.
* See the TraceLevel enum for values.
*/
traceLevel ?: TraceLevel
/**
* Most of these options are advanced aside from "profile"
*/
pipeline ?: PipelineConfig
/** Only needed if using Spokestack.classify */
nlu ?: NLUConfig
/**
* Only required for wakeword
* Most options are advanced aside from
* filter, encode, and decode for specifying config files.
*/
wakeword ?: WakewordConfig
/**
* Only required for the keyword recognizer
* Most options are advanced aside from
* filter, encode, decode, metadata, and classes.
*/
keyword ?: KeywordConfig
} 显示较低数字的日志记录数量意味着更多的日志。
•调试= 10
types.ts:58
•信息= 30
types.ts:60
•无= 100
types.ts:61
• perf = 20
types.ts:59
管道配置文件根据您的需求设置了语音管道
• ptt_native_asr = 2
当语音管道处于活动状态时,Apple/Android自动语音识别即将开始。当不使用WakeWord时,这可能是更常见的配置文件。
types.ts:24
• ptt_spokestack_asr = 5
当语音管道处于活动状态时,Spokestack自动语音识别即将出现。当不使用WakeWord时,这可能是更常见的配置文件,但是Spokestack ASR是首选的。
types.ts:42
• tflite_wakeword_keyword = 6
VAD敏感的tflite唤醒词激活tflite关键字识别器
types.ts:46
• tflite_wakeword_native_asr = 0
设置Wakeword并使用本地Apple/Android ASR。请注意,如果使用任何WakeWord配置文件,则需要WakeWord.Filter,Wakeword.encode和Wakeword.DeTect。
types.ts:12
• tflite_wakeword_spokestack_asr = 3
设置Wakeword并使用远程Spokestack ASR。请注意,如果使用任何WakeWord配置文件,则需要WakeWord.Filter,Wakeword.encode和Wakeword.DeTect。
types.ts:30
• vad_keyword_asr = 7
VAD触发的Tflite关键字识别器
types.ts:50
• vad_native_asr = 1
当语音主动检测触发它时,Apple/Android自动语音识别正在启用。
types.ts:17
• vad_spokestack_asr = 4
Spokestack自动语音识别正在触发声音触发时。
types.ts:35
• Optional agcompressiongaindb : number
advanced
仅适用于Android ocousticgainConcontrol
目标峰值音频级别,以-db为in -db,以保持-9dB的峰值,配置一个9
types.ts:192
• Optional agctargetleveldbfs : number
advanced
仅适用于Android ocousticgainConcontrol
DBF中的动态范围压缩率
types.ts:200
• Optional弹头: "aggressive" | "very-aggressive" | "mild" | "medium"
advanced
仅适用于Android的声音抑制器
噪声政策
types.ts:183
• Optional bufferwidth : number
advanced
缓冲宽度,与框架宽度一起确定缓冲尺寸
types.ts:155
• Optional框架: number
advanced
语音框架宽度,在MS中
types.ts:149
• Optional配置文件: PipelineProfile
配置文件是管道阶段的常见配置集合。
如果未明确设置配置文件,则Spokestack根据传递给Spokestack.initialize()配置确定明智的默认配置文件:
如果设置了Wakeword配置文件(未关键字配置),则将默认设置为TFLITE_WAKEWORD_NATIVE_ASR 。
如果设置了关键字配置文件(并且不是WakeWord Config),则默认值将设置为VAD_KEYWORD_ASR 。
如果设置了WakeWord和关键字配置文件,则将默认设置为TFLITE_WAKEWORD_KEYWORD 。
否则,默认值为PTT_NATIVE_ASR 。
types.ts:139
• Optional采样: number
音频采样率,Hz
types.ts:143
• Optional VadfallDelay : number
advanced
在MS中,降边的检测长度;此值确定必须收到多少个负样本才能将检测器翻转为负
types.ts:166
• Optional VADMODE : "quality" | "low-bitrate" | "aggressive" | "very-aggressive"
语音活动探测器模式
types.ts:159
• Optional vadrisedelay : number
advanced
仅Android
MS中的上升边缘检测长度;该值确定必须收到多少个正样本才能将检测器翻转为正
types.ts:175
•元数据: string | number
NLU元数据的JSON文件。如果指定,也需要模型和词汇。
该字段接受两种值类型。
require或import的源对象(例如metadata: require('./metadata.sjson') )。重要的是:当使用或导入require或import时,用于本地元数据JSON文件( .sjson )的特殊扩展名,以便在包含时不会解析该文件,而是将其作为源对象导入。这使得该文件是由基础本机库读取和解析的。
types.ts:223
•型号: string | number
NLU TensorFlow-Lite模型。如果指定,也需要元数据和词汇。
该字段接受两种值类型。
require或import的源对象(例如model: require('./nlu.tflite') ) types.ts:211
•词汇: string | number
包含NLU词汇的TXT文件。如果指定,也需要模型和元数据。
该字段接受两种值类型。
require或import检索的源对象(例如vocab: require('./vocab.txt') ) types.ts:231
• Optional输入长度: number
types.ts:244
•检测: string | number
“检测” TensorFlow-Lite模型。如果指定,也需要过滤和编码。
该字段接受两种值类型。
require或import检索的源对象(例如detect: require('./detect.tflite') )编码模型用于在MEL框架上执行每个自回归步骤;它的输入应形成[Mel-Length,Mel宽度]及其输出[Encode-Width],并具有附加的状态输入/输出形状[州宽度]
types.ts:272
•编码: string | number
“编码” TensorFlow-Lite模型。如果指定,也需要过滤和检测。
该字段接受两种值类型。
require或import的源对象(例如encode: require('./encode.tflite') )它的输入应形成[编码长度,encode宽度],并将其输出
types.ts:283
•过滤器: string | number
“滤波器” TensorFlow-Lite模型。如果指定,也需要检测和编码。
该字段接受两种值类型。
require或import的源对象(例如filter: require('./filter.tflite') )滤波器模型用于从线性STFT计算MEL频谱图;它的输入应形成[FFT宽度],其输出[MEL WIDTH]
types.ts:260
• Optional ActiveMax : number
advanced
激活的最大长度,以毫秒为单位,用于超时激活
types.ts:373
• Optional激活素: number
advanced
激活的最小长度,以毫秒为单位,用于忽略Wakeword后的VAD停用
types.ts:366
• Optional请求时间: number
仅ios
允许Apple ASR请求运行的时间长度,以毫秒为单位。苹果的无证限额为60000ms。
types.ts:380
• Optional rmsalpha : number
advanced仅Android
当前RMS信号能量的指数加权移动平均值(EWMA)更新速率(无RMS标准化为0)
types.ts:397
• Optional rmstarget : number
advanced仅Android
所需的线性均方根(RMS)信号能,用于信号归一化,应调整为训练期间使用的RMS目标
types.ts:389
• Optional唤醒字: string | string []
仅ios
只有在不传递过滤器,检测和编码路径时,需要有序的数组或逗号分隔的Wakeword关键字列表。
types.ts:404
•检测: string | number
“检测” TensorFlow-Lite模型。如果指定,也需要过滤和编码。
该字段接受两种值类型。
require或import检索的源对象(例如detect: require('./detect.tflite') )编码模型用于在MEL框架上执行每个自回归步骤;它的输入应形成[Mel-Length,Mel宽度]及其输出[Encode-Width],并具有附加的状态输入/输出形状[州宽度]
types.ts:272
•编码: string | number
“编码” TensorFlow-Lite模型。如果指定,也需要过滤和检测。
该字段接受两种值类型。
require或import的源对象(例如encode: require('./encode.tflite') )它的输入应形成[编码长度,encode宽度],并将其输出
types.ts:283
•过滤器: string | number
“滤波器” TensorFlow-Lite模型。如果指定,也需要检测和编码。
该字段接受两种值类型。
require或import的源对象(例如filter: require('./filter.tflite') )滤波器模型用于从线性STFT计算MEL频谱图;它的输入应形成[FFT宽度],其输出[MEL WIDTH]
types.ts:260
需要metadata或classes ,它们是相互排斥的。
•元数据: string | number
关键字元数据的JSON文件。如果未指定keyword.classes 。
该字段接受两种值类型。
require或import的源对象(例如metadata: require('./metadata.sjson') )。重要的是:当使用或导入require或import时,用于本地元数据JSON文件( .sjson )的特殊扩展名,以便在包含时不会解析该文件,而是将其作为源对象导入。这使得该文件是由基础本机库读取和解析的。
types.ts:424
•类: string | string []
逗号分隔的列表或关键字的班级名称阵列。当识别事件提出时,与最可能类相对应的名称将在成绩单字段中返回。如果未指定keyword.metadata 。
types.ts:434
这些属性可以将其传递给wakeword或keyword配置对象,但未共享。
• Optional编码: number
advanced
用作分类器的输入的编码器输出的滑动窗口的长度,以毫秒为单位
types.ts:293
• Optional编码: number
advanced
编码器输出的大小,在向量单元中
types.ts:299
• Optional ffthoplength : number
advanced
每次计算重叠的STFT时跳过的时间长度,以毫秒为单位
types.ts:322
• Optional fftwindowsize : number
advanced
用于计算STFT的信号窗口的大小,样品数量 - 应为2的功率,以达到最大效率
types.ts:306
• Optional fftWindowType : string
advanced
仅Android
在计算STFT之前,将窗口功能的名称应用于每个音频框架;目前支持“ Hann”窗口
types.ts:315
• Optional MelframeLength : number
advanced
每次计算重叠的STFT时跳过的时间长度,以毫秒为单位
types.ts:329
• Optional MelframeWidth : number
advanced
每个MEL频谱图的大小,滤纸组件的数量
types.ts:336
• Optional重点: number
advanced
重点滤波器的重量适用于标准化音频信号(0,无重音)
types.ts:343
• Optional州宽: number
advanced
编码器状态的大小,在向量单元中(默认为唤醒字段宽度)
types.ts:349
• Optional阈值: number
advanced
分类器后输出的阈值在上面激活管道,范围内[0,1]
types.ts:356
Apache-2.0
版权2021 Spokestack