zoukankan      html  css  js  c++  java
  • vue 页面文字转播放声音

    vue 页面文字转播放声音

    1、引入这句话

    const synth = window.speechSynthesis;
    const msg = new SpeechSynthesisUtterance();

    2、引入声音的方法

    /** 语音播报的函数/
    handleSpeak(e){
    msg.text = e;
    msg.lang = 'zh-CN';
    msg.volume = '1';
    msg.rate = 1;
    msg.pitch = 1;
    synth.speak(msg);
    },
    /
    * 语音停止 */
    handleStop(e){
    msg.text = e;
    msg.lang = 'zh-CN';
    synth.cancel(msg);
    }

    3、需要使用的地方调用

    /* 语音播放 */
    this.handleSpeak('你好,有新的告警信息产生啦');

    致敬:2020年的自己
    --------------------------------------------
    即使不为了什么远大理想,为了好好生活,你也得努力奋斗啊,不然别说什么风花雪月了,柴米油盐也能让你一筹莫展。
  • 相关阅读:
    二级JAVA考证笔记
    JAVA异常处理机制
    notepad++安装nppFTP
    nginx conf_ctx ****
    ngx_string()错误分析
    nginx
    char *p[] 和char**的思考
    LeetCode.接雨水
    LeetCode.atoi
    LeetCode.数字转罗马数字
  • 原文地址:https://www.cnblogs.com/zhukaixin/p/14620742.html
Copyright © 2011-2022 走看看