在flutter中向文字辛格尔顿班的讲话
我正在使用此 library 用于stt。
它说
初始化一次
初始化方法只需要每次应用一次一次 会议。在此之后,开始,停止和取消可以使用 与插件交互。随后的初始化电话被忽略 这是安全的,但确实意味着OnStatus和OnError回调 在第一次初始化后无法重置。因此 每个应用程序应只有一个插件的实例。这 SecripTotextProvider是创建单个实例并轻松的一种方法 在多个小部件中重复使用。
我的代码:
final SpeechToText speech = SpeechToText();
SpeechToTextProvider? speechProvider;
Future<void> initSpeechState() async {
await speechProvider?.initialize();
}
@override
void initState() {
super.initState();
speechProvider = SpeechToTextProvider(speech);
initSpeechState();
}
问题是我在根状态下定义了这一点,并且在iOS和Android中效果很好,但是这种初始化方法询问iOS side的App启动状态的权限。我想做的是,应该在文本屏幕上询问演讲中的权限(识别,麦克风)。我可以在单身人士中定义这个提供商,并在需要此提供商时称其为称呼吗?每个应用会话只能初始化一次。
I am using this library for stt.
it says that
Initialize once
The initialize method only needs to be called once per application
session. After that listen, start, stop, and cancel can be used to
interact with the plugin. Subsequent calls to initialize are ignored
which is safe but does mean that the onStatus and onError callbacks
cannot be reset after the first call to initialize. For that reason
there should be only one instance of the plugin per application. The
SpeechToTextProvider is one way to create a single instance and easily
reuse it in multiple widgets.
my code:
final SpeechToText speech = SpeechToText();
SpeechToTextProvider? speechProvider;
Future<void> initSpeechState() async {
await speechProvider?.initialize();
}
@override
void initState() {
super.initState();
speechProvider = SpeechToTextProvider(speech);
initSpeechState();
}
The problem is that i define this in my root state and it works good in ios and android but this initializing method ask permissions from app launch state in ios side. What i would like to do is it should ask permissions (recognition, microphone) in the speech to text screen. Can i define this provider in a singleton and call it whenever i need this provider? It should initialize only once for per appliciation session.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
Use isAvailable property to check if the provider has already been initialized.