android 意大利语_制作方法:带有意大利语语的音乐家抽认卡

android 意大利语

android 意大利语

Update: Now in French too Update 2: and in German Update 3: now with Web Speech API (scroll to the bottom)

更新:现在也使用法语更新2:和德语更新3:现在具有Web Speech API (滚动到底部)

Here's a little app that gives you flashcards of Italian words used in music: https://www.onlinemusictools.com/italiano/ It also pronounces the words in four different voices.

这是一个小应用程序,可为您提供音乐中使用的意大利语单词的抽认卡: https : //www.onlinemusictools.com/italiano/它还可以四种不同的语音发音。

The code for the tool: https://github.com/stoyan/italiano

该工具的代码: https : //github.com/stoyan/italiano

A few implementation notes after the break (screenshot).

休息后的一些实施注意事项(屏幕截图)。

ReactCRA-ft (React CRA-ft)

The tool is a little React app. Its bones are generated by create-react-app. It also uses a wee additional tool I call CRAFT (Create React App From Template). More about these here.

该工具是一个小的React应用程序。 它的骨骼是由create-react-app生成的。 它还使用一个称为CRAFT(从模板创建React App)的附加工具。 更多关于这些在这里

维基百科表格到JSON (Wikipedia Table-to-JSON)

The Italian words I found on Wikipedia, neatly divided into sections and tables. Just as I opened the browser console to start hacking on a script to scrape these tables, I remembered I already have a tool for that!

我在Wikipedia上找到的意大利语单词整齐地分成了部分和表格。 当我打开浏览器控制台开始破解脚本以刮擦这些表时,我记得我已经有一个工具

The process wasn't completely lacking manual intervention, but relatively painlessly I got a nice chunk of JSON files, one for each category of words, check'em out.

这个过程并非完全没有人工干预,但是相对不费吹灰之力,我得到了一大堆JSON文件,每个单词类别一个,请检查一下

说话 (Speak)

The cute part about this tool is the pronunciation of the words. For this, I reached to the help of MacOS's say command-line tool. This tool comes free with the OS and you can tweak the voices in your Accessibility preferences (short post about all that here).

这个工具最可爱的部分是单词的发音。 为此,我接触了MacOS的say命令行工具。 该工具随操作系统一起免费提供,您可以在“辅助功能”首选项中进行调整(有关此内容的简短文章)。

I thought I'd write a script to loop thought the JSON files and then say each word of each file with each of the 4 Italian voices that are available.

我以为我会写一个脚本来循环考虑JSON文件,然后用可用的4种意大利语语音中的每一个say每个文件的每个单词。

You can see the whole script but here's just the main loop:

您可以看到整个脚本,但这只是主循环:

readDir(dataDir).forEach(f => {
  if (f.startsWith('.')) {
    return; // no .DS_Store etc, thank you
  }
  const file = path.resolve(dataDir, f);
  const jsonData = require(file);
  [
    "Alice",
    "Federica",
    "Luca",
    "Paola",
  ].forEach(voice => {    
    jsonData.forEach(definition => {
      const word = definition[0];
      const outfile = `voices/${voice}/${justLetters(word)}`; // .aiff is assumed
      console.log(outfile);
      spawn('say', ['-v', voice, '-o', outfile, word]);
    });
  });
});

So if you have the word "Soprano" the script runs:

因此,如果您有单词“ Soprano”,则脚本将运行:

say -v Alice -o voices/Alice/soprano Soprano

... then Federica instead of Alice and so on, for each of the 4 voices. And you end up with voices/Alice/soprano.aiff audio file.

...然后是费德里卡(Federica)而不是爱丽丝(Alice)等,分别代表这四种声音。 最后,您得到了voices/Alice/soprano.aiff音频文件。

Once all is done, you go in each voice's dir and convert all AIFF files to smaller, compressed MP3 using ffmpeg:

完成所有操作后,您进入每个声音的目录,然后使用ffmpeg将所有AIFF文件转换为较小的压缩MP3:

for f in *.aiff; do ffmpeg -i $f "${f%.*}.mp3"; done

And delete the sources:

并删除源:

rm -rf *.aiff

重用语言数据 (Reuse the language data)

Please. My tool/UI is out there for you to practice, but I know there are tons of flashcard-style and language-learning apps out there. If you want to take the structured data I hereby slaved over and import it to your favorite app, the JSON and MP3 files are self-contained in this directory: tree/master/public/italiano.

请。 我的工具/ UI在那里供您练习,但是我知道那里有大量的抽认卡样式和语言学习应用程序。 如果要接收我据此继承的结构化数据并将其导入到您喜欢的应用程序中,则JSON和MP3文件在以下目录中是独立的: tree / master / public / italiano

Let me know if you do something with this.

让我知道您是否对此有所作为。

说-v Stoyan Ciao cari! (say -v Stoyan Ciao cari!)

Thanks for reading! Enjoy the flashcards and say and all that.

谢谢阅读! 享受抽认卡, say所有这些。

更新:Web Speech API (Update: Web Speech API)

Thanks to Marcel Duran's tweet I figured I was living under a rock and missed out on all the fun that is the Web Speech API.

多亏了Marcel Duran的鸣叫,我才知道自己生活在一块石头下,错过了Web Speech API的所有乐趣。

So for browsers that support that API which is a lot of browsers, people don't need to download MP3 and the whole say jazz is unnecessary. These words can be generated in the browser. Yeweeyeye! Yaw! Yeet!

因此,对于浏览器的支持,API这是很多浏览器,人们并不需要下载MP3和整个say爵士是不必要的。 这些词可以在浏览器中生成。 红眼! 偏航! !!

First bump though - browsers. See what happens when you try to check what voices are available:

不过,第一个障碍-浏览器。 查看当您尝试检查可用声音时会发生什么:

Huh? You call the same thing and get different results. Not cool. Turns out in FF and Chrome this API is asynchronous. And the right way is to subscribe to an event:

?? 您称相同的事物并获得不同的结果。 不酷事实证明,在FF和Chrome中,此API是异步的。 正确的方法是订阅事件:

speechSynthesis.onvoiceschanged = () => {
  voices = speechSynthesis.getVoices().filter(v => v.lang === 'it-IT');
}

Cool. Turns out in Safari there's no onvoiceschanged. But getVoices() appeared synchronous in my testing.

凉。 事实证明,在Safari中没有onvoiceschanged 。 但是getVoices()在我的测试中似乎是同步的。

So with all the browser sniffing, here's what I ended up with in order to get a list of Italian-speaking voices:

因此,随着所有浏览器的嗅探,以下是我得到的结果,以便获得说意大利语的声音的列表:

let webvoices = null;
if (
  'SpeechSynthesisUtterance' in window &&
  'speechSynthesis' in window
) {
  if ('onvoiceschanged' in speechSynthesis) {
    speechSynthesis.onvoiceschanged = () => {
      webvoices = getVoices();
    }
  } else if (speechSynthesis.getVoices) {
      webvoices = getVoices();
  }
}

function getVoices() {
  return speechSynthesis.getVoices().filter(v => v.lang === 'it-IT' && v.localService);
}

(The localService bit is so that there's no download, because Chrome offers more voices but they require internet connection)

( localService位用于禁止下载,因为Chrome提供了更多的声音,但它们需要互联网连接)

Now webvoices is my array of Italian speakers and I randomly pick one every time you hit Say.

现在, webvoices是我的一组意大利语讲者,每当您说“说”时,我都会随机选择一名。

If webvoices is still null, I fall back to what I had before.

如果webvoices仍然为空,那么我会回到以前的状态。

    if (webvoices) {
      const u = new SpeechSynthesisUtterance(term[0]);
      u.voice = webvoices[Math.floor(Math.random() * webvoices.length)];
      speechSynthesis.speak(u);
    } else {
      this.state.audio[Math.floor(Math.random() * this.state.audio.length)].play();  
    }

Awesome! Here's the diff and the Safari follow-up.

太棒了! 这是diffSafari的后续文章

Update: moved back to the MP3 while keeping the web speech for offline use. I just didn't like how it sounds in French, especially words like "prelude" (sounds like prelune) and "rapide" (again sounds like rapine)

更新:移回MP3,同时保留网络语音以供离线使用。 我只是不喜欢怎么听起来在法国,尤其是像“前奏”(如prelune声音)和“RAPIDE”(再次听起来像是抢劫)

Tell your friends about this post on Facebook and Twitter

FacebookTwitter上告诉您的朋友有关此帖子的信息

翻译自: https://www.phpied.com/how-its-made-italian-slang-musicians/

android 意大利语

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值