#752 | 2020-03-28 17:41:21

才知道浏览器有这么个API:https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis

speak('Google 普通话(中国大陆)', '故生于忧患 死于安乐')
speak('Google US English', 'fuck me you fucking fuck')

function speak (lang, text) {
  const synth = window.speechSynthesis
  let voices = synth.getVoices().filter(v => v.name === lang)
  if (voices.length == 0) return
  let utterThis = new SpeechSynthesisUtterance(text)
  utterThis.voice = voices[0]
  synth.speak(utterThis)
}

声音很真实了……