gs-translate-speak
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

INSTALL

npm i gs-translate-speak

EXAMPLE

Example for Interpreter

//const { Interpreter } = require("gs-translate-speak");  // cjs
import { Interpreter } from "gs-translate-speak"

(async () => {
  let speaker = new Interpreter({
    input: "xin chào việt nam",
    to: "en",
    speed:1 //support interger -2 <->2
  })

  let output = await speaker.translate()
  console.log(output) // Hello Vietnam

  speaker.read("hello bro, im tvhop2201")
  let output2 = await speaker.translate("vi")
  console.log(output2) // xin chào anh, tôi là tvhop2201


  let voice = await speaker.say() // return base64
  fs.writeFileSync("./hehe.mp3", voice, { encoding: 'base64', })

})()

Example for Simple

//const { Simple } = require("gs-translate-speak");  // cjs
import { Simple } from "gs-translate-speak"

(async () => {
  let T = new Simple()

  let detect = await T.detect({
    to: "vi",
    input: "Hello Viet Nam",
  })
  console.log(detect) // { language: 'en', confidence: 0.32941613, spell: {} 

  let output = await T.translate({
    to: "vi",
    input: "Hello Viet Nam",
  })
  console.log(output) //Xin chào Việt Nam

  let voice = await T.speak({ input: "anh hợp vạn tuế", to: "vi" }) //return base 64
  fs.writeFileSync("./hehe2.mp3", voice, { encoding: 'base64', }) //save the voice

})()

Using proxy

new Interpreter({
  to: "vi",
  input: "Hello Viet Nam",
  proxy: "http://username:password@geo.iproyal.com:port"
})

new Simple({
  to: "vi",
  input: "Hello Viet Nam",
  proxy: "http://username:password@geo.iproyal.com:port"
})

Options

{
  from?: string,
  to?: string,
  host?: string,
  proxy?: string,
  input?: string,
}

Package Sidebar

Install

npm i gs-translate-speak

Weekly Downloads

10

Version

1.0.5

License

ISC

Unpacked Size

47.9 kB

Total Files

13

Last publish

Collaborators

  • hoptv