1

https://github.com/bradmartin/nativescript-texttospeech

texttospeech has documentation written in TS.

How to translate code into ns-VUE?

import { TNSTextToSpeech, SpeakOptions } from 'nativescript-texttospeech';

let TTS = new TNSTextToSpeech();

let speakOptions: SpeakOptions = {
  text: 'hello world',
};

TTS.speak(speakOptions); 

I don't want to use typescript, all I need is a button that talks in Nativescript-Vue .

Thanks in advance

1
  • Typescript is just a superscript to javascript. If you have native javascript code it will work just the same. Are you getting any errors when building? Commented Nov 15, 2019 at 16:10

2 Answers 2

1

Just remove the type from the speakOptions and remove it from the import:

import { TNSTextToSpeech } from 'nativescript-texttospeech';

let TTS = new TNSTextToSpeech();

let speakOptions = {
  text: 'hello world',
};

TTS.speak(speakOptions); 
Sign up to request clarification or add additional context in comments.

Comments

0

If anyone else is trying to convert TS to vanilla JS please try TypeScript Playground

This was what I was trying to do.


<template>
  <Page>
    <ActionBar title="Welcome" />
    <StackLayout>
      <Label class="message" :text="speakOptions.text" col="0" row="0" />
      <Button text="talk" @tap="talk('welcome')" />
    </StackLayout>
  </Page>
</template>

<script >
import { TNSTextToSpeech } from "nativescript-texttospeech";

let TTS = new TNSTextToSpeech();

export default {
  data() {
    return {
      speakOptions: {
        text: "hello"
      }
    };
  },
  methods: {
    talk: function(message) {
      this.speakOptions.text = message;
      TTS.speak(this.speakOptions);
    }
  }
};
</script>

<style scoped>
</style>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.