Getting Started with the Vue SpeechToText Component in Vue 2
22 Jul 20265 minutes to read
This article provides a step-by-step guide for setting up a Vue 2 project using Vue-CLI and integrating the Syncfusion® Vue SpeechToText component.
Prerequisites
| Requirement | Version |
|---|---|
| Vue | 2.6 or higher |
| Node.js | 16.0.0 or above |
Vue supported versions
| Vue version | Minimum Syncfusion Vue SpeechToText version |
|---|---|
| Vue v2.7 | 20.3.47 and above |
| Vue v3.0 | 19.2.44 and above |
Browser support
| Browser | Supported versions |
|---|---|
| Chrome | Latest |
| Firefox | Latest |
| Opera | Latest |
| Edge | 13+ |
| Internet Explorer (IE) | 11+ |
| Safari | 9+ |
| iOS Safari | 9+ |
| Android Browser / Chrome for Android | 4.4+ |
| Windows Mobile | IE 11+ |
Setup the Vue 2 project
Easily set up a Vue 2 application using Vue CLI, which provides a reliable development environment, a streamlined project structure, and optimized builds compared to older setup tools. For detailed steps, refer to the Vue CLI installation instructions.
To create a new Vue 2 application, run the following commands based on your preferred package manager:
npm install -g @vue/cli
vue create quickstartor
yarn global add @vue/cli
vue create quickstartDuring the setup process, the CLI will prompt you for a few configuration options. Select the following:
- Which linter to use? → Default ([Vue 2] babel, eslint)
- Install with npm and start now? → Yes
Selecting Yes automatically installs the project dependencies and starts the development server.
After verifying that the application starts successfully, terminate the development server in the terminal and proceed to the next step.
Navigate to the project directory:
cd quickstartAdding Vue SpeechToText packages
To install the SpeechToText package, use the following command:
npm install @syncfusion/ej2-vue-inputs --saveor
yarn add @syncfusion/ej2-vue-inputsAdding CSS reference
Themes for Syncfusion® Vue components can be applied using CSS files provided through npm theme packages. For available themes, refer to the Themes documentation.
Install the Material 3 theme package using the following command:
npm install @syncfusion/ej2-material3-theme --saveThen add the following CSS reference to the src/App.vue file:
<style>
@import "../node_modules/@syncfusion/ej2-material3-theme/styles/speech-to-text/index.css";
</style>Adding SpeechToText component
The SpeechToText code should be added in the src/App.vue file.
<template>
<div id='container'>
<ejs-speechtotext id="speechtotext" @transcriptChanged="onTranscriptChange"></ejs-speechtotext>
<ejs-textarea ref="textareaObj" rows="5" cols="50" value="" resize-mode="None" placeholder="Transcribed text will be shown here..."></ejs-textarea>
</div>
</template>
<script>
import { SpeechToTextComponent, TextAreaComponent } from "@syncfusion/ej2-vue-inputs";
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
export default {
components: {
"ejs-speechtotext": SpeechToTextComponent,
"ejs-textarea": TextAreaComponent
},
methods: {
onTranscriptChange: function(args) {
this.$refs.textareaObj.ej2Instances.value = args.transcript;
}
}
}
</script>
<style>
@import "../node_modules/@syncfusion/ej2-tailwind3-theme/styles/speech-to-text/index.css";
#container {
margin: 50px auto;
gap: 20px;
display: flex;
flex-direction: column;
align-items: center;
}
</style>Run the application
npm run serveor
yarn run serveThe SpeechToText component requires an internet connection and browser support for the Speech Recognition API.
Registering your Syncfusion license
Generate a license key from the Syncfusion License Dashboard and register it before rendering your Vue 2 application:
```javascript
import { registerLicense } from '@syncfusion/ej2-base';
registerLicense('YOUR_LICENSE_KEY');
```Note: A valid Syncfusion license is required for production use. Without a valid license, a trial license warning message will be displayed.
Troubleshooting
-
SpeechToText not rendering styles: Ensure the theme CSS is imported in
src/App.vueand that any default Vue CLI starter styles are not overriding the SpeechToText styles. -
Trial license warning banner: Register a license key via
registerLicense()from@syncfusion/ej2-base.