use-speak
v1.5.1
Published
A composition api for SpeechSynthesis, supports vue2.0 and vue3.0
Downloads
27
Maintainers
Readme
use-speak
A composition api for SpeechSynthesis, supports vue2.0 and vue3.0
Installing
# use pnpm
$ pnpm install use-speak
# use npm
$ npm install use-speak --save
# use yarn
$ yarn add use-speak
Usage
Use in Vue >=3.0
<script setup>
import { getCurrentInstance, onMounted } from 'vue'
import useSpeak from 'use-speak'
const speaker = useSpeak({ lang: 'zh_CN' })
onMounted(() => {
speaker.speak('new bee')
})
useExpose({ speaker })
</script>
Use in Vue 2.7
<script>
import useSpeak from 'use-speak'
export default {
setup() {
const speaker = useSpeak({ lang: 'zh_CN' })
speaker.speak('new bee')
return { speaker }
}
}
</script>
Use in Vue <=2.6
Add
@vue/composition-api
to theproject.json
dependencies and run install.
{
"dependencies": {
"@vue/composition-api": "latest"
}
}
// main.js
import Vue from 'vue'
import VueCompositionApi from '@vue/composition-api'
Vue.use(VueCompositionApi)
new Vue({}).$mount('#app')
<script>
import useSpeak from 'use-speak'
export default {
setup() {
const speaker = useSpeak({ lang: 'zh_CN' })
speaker.speak('new bee')
return { speaker }
}
}
</script>
Using unpkg CDN
<script src="https://unpkg.com/vue-demi@latest/lib/index.iife.js"></script>
<script src="https://unpkg.com/[email protected]/dist/index.global.prod.js"></script>
Support & Issues
Please open an issue here.