win32-allvoices.js 612 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env node
  2. // Usage:
  3. // ./allvoices.js
  4. //
  5. // Iterates over all supported voices and
  6. // repeats the input phrase
  7. const say = require('../')
  8. let voices = [
  9. { voice: 'Microsoft David Desktop', text: 'No people recognize me by my voice.' },
  10. { voice: 'Microsoft Zira Desktop', text: 'No people recognize me by my voice.' }
  11. ]
  12. sayIt(0)
  13. function sayIt (voice) {
  14. let v = voices[voice]
  15. console.log(v.voice)
  16. say.speak(v.text, v.voice, 1, (err) => {
  17. voice++
  18. if (err) {
  19. console.error(err)
  20. }
  21. if (voice >= voices.length) {
  22. process.exit(0)
  23. }
  24. sayIt(voice)
  25. })
  26. }