Flutter dart:tml和dart:js未找到错误颤振

Flutter dart:tml和dart:js未找到错误颤振,flutter,text-to-speech,Flutter,Text To Speech,我正在尝试在我的聊天应用程序中使用语音对文本和文本对语音功能来制作语音信息。我完全遵循了这个文档。但我不得不导入另一个名为flatter_tts_web.dart的库。我认为这应该不是什么大问题,但它似乎导致了很大的错误。这是stacktrace ../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:2:8: Error: Not found: 'dart:

我正在尝试在我的聊天应用程序中使用语音对文本和文本对语音功能来制作语音信息。我完全遵循了这个文档。但我不得不导入另一个名为flatter_tts_web.dart的库。我认为这应该不是什么大问题,但它似乎导致了很大的错误。这是stacktrace

../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:2:8: Error: Not found: 'dart:html'
import 'dart:html' as html;
       ^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:3:8: Error: Not found: 'dart:js'
import 'dart:js';
       ^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:31:3: Error: Type 'html.SpeechSynthesis' not found.
  html.SpeechSynthesis synth;
  ^^^^^^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:32:3: Error: Type 'html.SpeechSynthesisUtterance' not found.
  html.SpeechSynthesisUtterance utterance;
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:31:8: Error: 'SpeechSynthesis' isn't a type.
  html.SpeechSynthesis synth;
       ^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:32:8: Error: 'SpeechSynthesisUtterance' isn't a type.
  html.SpeechSynthesisUtterance utterance;
       ^^^^^^^^^^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:37:17: Error: Method not found: 'SpeechSynthesisUtterance'.
    utterance = html.SpeechSynthesisUtterance();
                ^^^^^^^^^^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:38:18: Error: Getter not found: 'window'.
    synth = html.window.speechSynthesis;
                 ^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:156:63: Error: 'JsArray' isn't a type.
        context['speechSynthesis'].callMethod('getVoices') as JsArray<dynamic>;
                                                              ^^^^^^^
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart:156:9: Error: The getter 'context' isn't defined for the class 'FlutterTtsPlugin'.
 - 'FlutterTtsPlugin' is from 'package:flutter_tts/flutter_tts_web.dart' ('../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_tts-1.2.6/lib/flutter_tts_web.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'context'.
        context['speechSynthesis'].callMethod('getVoices') as JsArray<dynamic>;
        ^^^^^^^
/C:/flutter/packages/flutter_web_plugins/lib/src/plugin_registry.dart:29:5: Error: Method not found: 'webOnlySetPluginHandler'.
    ui.webOnlySetPluginHandler(_binaryMessenger.handlePlatformMessage);
    ^^^^^^^^^^^^^^^^^^^^^^^
Unhandled exception:
FileSystemException(uri=
org-dartlang-untranslatable-uri:dart%3Ahtml; message=StandardFileSystem only supports file:* and data:* URIs)
#0      StandardFileSystem.entityForUri (package:front_end/src/api_proto
type/standard_file_system.dart:33:7)
#1      asFileUri (package:vm/kernel_front_end.dart:659:37)
#2      writeDepfile (package:vm/kernel_front_end.dart:853:21)
<asynchronous suspension>
#3      FrontendCompiler.compile (package:frontend_server/frontend_server.dart:574:15)
<asynchronous suspension>
#4      _FlutterFrontendCompiler.compile (package:flutter_frontend_server/server.dart:43:22)
#5      starter (package:flutter_frontend_server/server.dart:182:27)
#6      main (file:///C:/b/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:9:30)
#7      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#8      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)



FAILURE: Build failed with an exception.

* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 896

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 38s
Exception: Gradle task assembleDebug failed with exit code 1
。/../AppData/Local/Pub/Cache/hosted/Pub.dartlang.org/flatter\u tts-1.2.6/lib/flatter\u tts\u web.dart:2:8:错误:未找到:“dart:html”
将“dart:html”导入为html;
^
../../AppData/Local/Pub/Cache/hosted/Pub.dartlang.org/flatter_tts-1.2.6/lib/flatter_tts_web.dart:3:8:错误:未找到:“dart:js”
导入“dart:js”;
^
../../AppData/Local/Pub/Cache/hosted/Pub.dartlang.org/flatter_tts-1.2.6/lib/flatter_tts_web.dart:31:3:错误:未找到类型“html.SpeechSynthesis”。
html.SpeechSynthesis;
^^^^^^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/Pub.dartlang.org/flatter_tts-1.2.6/lib/flatter_tts_web.dart:32:3:错误:未找到类型“html.speechsynthesistence”。
言语综合性话语;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/Pub.dartlang.org/flatter_tts-1.2.6/lib/flatter_tts_web.dart:31:8:错误:“SpeechSynthesis”不是一种类型。
html.SpeechSynthesis;
^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/Pub.dartlang.org/flatter_tts-1.2.6/lib/flatter_tts_web.dart:32:8:错误:“SpeechSynthesistTerance”不是类型。
言语综合性话语;
^^^^^^^^^^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/Pub.dartlang.org/flatter_tts-1.2.6/lib/flatter_tts_web.dart:37:17:错误:找不到方法:“SpeechSynthesistTerance”。
话语=html.SpeechSynthesisUtterance();
^^^^^^^^^^^^^^^^^^^^^^^^
../../AppData/Local/Pub/Cache/hosted/Pub.dartlang.org/flatter_tts-1.2.6/lib/flatter_tts_web.dart:38:18:错误:找不到Getter:“窗口”。
synth=html.window.speechSynthesis;
^^^^^^
../../AppData/Local/Pub/Cache/hosted/Pub.dartlang.org/flatter_tts-1.2.6/lib/flatter_tts_web.dart:156:63:错误:“JsArray”不是类型。
context['speechSynthesis'].callMethod('getVoices')作为JsArray;
^^^^^^^
../../AppData/Local/Pub/Cache/hosted/Pub.dartlang.org/flatter_tts-1.2.6/lib/flatter_tts_web.dart:156:9:错误:未为类“flatterttsplugin”定义getter“context”。
-“flatterttsplugin”来自“package:flatter_tts/flatter_tts_web.dart”(“../../AppData/Local/Pub/Cache/hosted/Pub.dartlang.org/flatter_tts-1.2.6/lib/flatter_tts_web.dart”)。
尝试将名称更正为现有getter的名称,或定义名为“context”的getter或字段。
context['speechSynthesis'].callMethod('getVoices')作为JsArray;
^^^^^^^
/C:/flatter/packages/flatter\u web\u plugins/lib/src/plugin\u注册表。dart:29:5:错误:找不到方法:“webOnlySetPluginHandler”。
ui.webOnlySetPluginHandler(_binaryMessenger.handlePlatformMessage);
^^^^^^^^^^^^^^^^^^^^^^^
未处理的异常:
FileSystemException(uri)=
org dartlang不可翻译的uri:dart%3Ahtml;message=StandardFileSystem仅支持文件:*和数据:*uri)
#0 StandardFileSystem.entityForUri(包:前端/src/api\u协议
类型/标准文件系统。dart:33:7)
#1 asFileUri(包:vm/kernel\u front\u end.dart:659:37)
#2 writedpfile(包:vm/kernel\u front\u end.dart:853:21)
#3 FrontendCompiler.compile(包:frontend_server/frontend_server.dart:574:15)
#4 _flatterfrontendcompiler.compile(包:flatter _frontendcompiler\server/server.dart:43:22)
#5启动器(包:颤振前端服务器/服务器。dart:182:27)
#6主要(file:///C:/b/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:9:30)
#7_星状。(省道:隔离补片/隔离补片。省道:299:32)
#8 RawReceivePortImpl.handleMessage(dart:隔离补丁/隔离补丁。dart:168:12)
失败:生成失败,出现异常。
*其中:
脚本“C:\flatter\packages\flatter\u tools\gradle\flatter.gradle”行:896
*出了什么问题:
任务“:app:compileFlutterBuildDebug”的执行失败。
>进程“command”C:\flatter\bin\flatter.bat“”以非零退出值1结束
*尝试:
使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。使用--scan运行以获得完整的洞察力。
*得到更多的帮助https://help.gradle.org
生成在1m 38s内失败
异常:Gradle任务assembleDebug失败,退出代码为1

我试图删除该文件,但变量Tts状态取决于web文件。A.所以我试着换了贝塔香奈儿。请尽快帮助我,因为这是一场黑客大赛,我还有8个小时。我将立即提供任何必要的代码

我认为这是因为dart未安装,请确保您正确安装了dart,并在安装dart后使用以下命令

pub get

我想你需要使用稳定通道。@LapaNyAinaTanjona不起作用。同样的错误你解决了吗?我这里也有同样的问题。@HyungTaeCarapetoFigur还有另一个文本到语音的插件,它工作得非常好。它也有同样的命运,但是有一种不同的方式来喂养它们,而文档并不是这样good@SiddharthAgrawal谢谢你让我知道。但我还是成功了。首先,我试图按照文档一步一步地完成它,然后出现了错误。但当我刚刚复制并粘贴他们的颤振项目示例时,它起了作用。然后我开始修改它以适应我的项目。我尝试过,但没有成功。现在我正在使用一个功能较少的独立库,因为我没有时间