GithubHelp home page GithubHelp logo

pekosman76 / vue-speech-reco Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 3.0 20 KB

Simple vue js way speech to text and text to speech

Vue 100.00%
vuejs speech-recognition speech-to-text text-to-speech js javascript html-css-javascript html5 vue-js vuejs2

vue-speech-reco's Introduction

Vue-Speech-Reco

Simple vue js way speech to text and text to speech Speech

Created two button with methods for speech to text and text to speech

<div class="speech-to-txt" @click="startTxtToSpeech">Speech to txt</div>
<div class="txt-to-speech" @click="startSpeechToTxt">Txt to speech</div>

Configuration for speech language

 data() {
   return {
     runtimeTranscription_: "",
     transcription_: [],
     lang_: "fr-FR"
   };
 },

Add Methods for start speech to text and text to speech

 methods: {
    startTxtToSpeech() {
      // initialisation of voicereco
      window.SpeechRecognition =
      window.SpeechRecognition || window.webkitSpeechRecognition;
      const recognition = new window.SpeechRecognition();
      recognition.lang = this.lang_;
      recognition.interimResults = true;

      // event current voice reco word
      recognition.addEventListener("result", event => {
        const text = Array.from(event.results)
          .map(result => result[0])
          .map(result => result.transcript)
          .join("");
        this.runtimeTranscription_ = text;
      });

      // end of transcription
      recognition.addEventListener("end", () => {
        this.transcription_.push(this.runtimeTranscription_);
        this.runtimeTranscription_ = "";
        recognition.stop();
      });
      recognition.start();
    },
    startSpeechToTxt() {
      // start speech to txt
      var utterance = new SpeechSynthesisUtterance("Message Envoyé");
      window.speechSynthesis.speak(utterance);
    }
  }

Speech documentation

https://developer.mozilla.org/fr/docs/Web/API/SpeechRecognition https://developer.mozilla.org/fr/docs/Web/API/Window/speechSynthesis

vue-speech-reco's People

Contributors

pekosman76 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.