|
本帖最后由 Cover-L 于 2021-8-25 11:26 编辑
代码:
- <template>
- <scroll-view class="main" scroll-y>
- <p style="line-height: 30px; text-indent: 2em;"></p> <textarea v-model="text"></textarea>
- <view class="box">
- <button class="btn" @click="config">config</button>
- <button class="btn" @click="startListening">startListening</button>
- <button class="btn" @click="stopListening">stopListening</button>
- <button class="btn" @click="cancel">cancel</button>
- <button class="btn" @click="addEventListener">addEventListener</button>
- <button class="btn" @click="destroy">destroy</button>
- </view>
- </scroll-view>
- </template>
- <style>
- .main {
- height: 100%;
- }
- .box {
- width: 100%;
- flex-wrap: wrap;
- justify-content: space-between;
- position: absolute;
- left: 0;
- bottom: 0;
- }
- .btn {
- width: 100%;
- height: 40px;
- text-align: center;
- line-height: 20px;
- margin-bottom: 20px;
- font-size: 18px;
- }
- textarea {
- width: 100%;
- height: 60px;
- font-size: 18px;
- color: dimgrey;
- }
- </style>
- <script>
- export default {
- name: 'test',
- data() {
- return {
- text: '好好学习',
- }
- },
- apiready() {
- this.config()
- },
- methods: {
- config() {
- var iflyEva = api.require('iflyEva');
- iflyEva.config({
- values: [
- { key: 'language', value: 'zh_cn' },
- { key: 'category ', value: 'read_sentence' },
- { key: 'result_level', value: 'complete' },
- { key: 'vad_bos', value: '5000' },
- { key: 'vad_eos', value: '1800' },
- { key: 'speech_timeout', value: '60000' },
- ]
- });
- },
- startListening() { //点击返回{"status":false,"mag":"startError - null"}
- var iflyEva = api.require('iflyEva');
- iflyEva.startListening({
- data: this.data.text
- }, function (ret) {
- api.alert({
- msg: JSON.stringify(ret)
- });
- });
- },
- stopListening() {
- var iflyEva = api.require('iflyEva');
- iflyEva.stopListening();
- },
- cancel() {
- var iflyEva = api.require('iflyEva');
- iflyEva.cancel();
- },
- addEventListener() {
- var iflyEva = api.require('iflyEva');
- iflyEva.addEventListener(function (ret) {
- api.alert({
- msg: JSON.stringify(ret)
- });
- });
- },
- destroy() {
- var iflyEva = api.require('iflyEva');
- iflyEva.destroy(function (ret) {
- api.alert({
- msg: JSON.stringify(ret)
- });
- });
- },
- }
- }
- </script>
复制代码 点击startListening()返回{"status":false,"mag":"startError - null"},哪里写的不对吗?
|
|