osx-allvoices.js 926 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env node
  2. // Usage:
  3. // node allvoices "Some phrase to say"
  4. // or
  5. // ./allvoices.js
  6. //
  7. // Iterates over all supported voices and
  8. // repeats the input phrase
  9. const say = require('../')
  10. let voices = [
  11. { voice: 'Alex', text: 'Most people recognize me by my voice.' },
  12. { voice: 'Amelie', text: 'Bonjour, je m’appelle Amelie. Je suis une voix canadienne.' },
  13. { voice: 'Kyoko', text: 'こんにちは、私の名前はKyokoです。日本語の音声をお届けします。' },
  14. { voice: 'Samantha', text: 'Hello, my name is Samantha. I am an American-English voice.' },
  15. { voice: 'Yuna', text: '안녕하세요. 제 이름은 Yuna입니다. 저는 한국어 음성입니다.' }
  16. ]
  17. sayIt(0)
  18. function sayIt (voice) {
  19. let v = voices[voice]
  20. console.log(v.voice)
  21. say.speak(v.text, v.voice, 1, () => {
  22. voice++
  23. if (voice >= voices.length) {
  24. process.exit(0)
  25. }
  26. sayIt(voice)
  27. })
  28. }