gwmatthews / Shirokuma-Cafe

A Japanese language learning resource.
https://gwmatthews.github.io/Shirokuma-Cafe/
GNU General Public License v2.0
9 stars 2 forks source link

Contributing #3

Open Marakai opened 4 years ago

Marakai commented 4 years ago

Can you update the docs on how to contribute? (red kokeshi here)

gwmatthews commented 4 years ago

Yes I can! Glad to hear you are interested!

Here's the basic idea though:

Each episode has a markdown file with the subtitles and links to audio clips. Audio clips are all numbered successively starting 001.mp3 and continuing and are contained in a folder named with the number of the episode.

So for episode 5 we have the file:

Shorokuma-Cafe-05.Rmd (This is an Rmarkdown file only because I use Rstudio to compile everything to html)

and it just consists of the text of the subtitles with links to audio clips below each bit of text. Here's an example:

---
title: "シロクマくん 動物園へ"
---

シロクマくん 動物園へ

<audio controls>
<source src="audio/05/001.mp3">
</audio><hr>

シロクマくん 暇だから 何か問題出してよ

いいよ

<audio controls>
<source src="audio/05/002.mp3">
</audio><hr>

...

The video files that I start from contain two episodes each -- that is why there are files called Shirokuma-Cafe-05-06 which are just plain text subtitle files stripped of all of the extra code.

So my workflow is:

  1. extract the audio from the video -- I use ffmpeg to do this on the command line, but there are plenty of other tools for this
  2. open up the text file with subtitles
  3. open up the audio in Audacity (or any other audio editor)
  4. listen to it and export clips to a numbered folder by selecting sections and exporting them to files numbered 001.mp3 and so on
  5. paste the audio tag with the appropriate folder and file number below each bit of text and then save the file as Shirokuma-Cafe-##.Rmd with ## as the number of the episode.
  6. then I recompile everything with Rstudio which generates the html files.

It's really pretty simple -- I use markdown files and Rstudio to save me from having to write lots of html files.

The time consuming part is obviously doing the audio editing and putting together the markdown files, but then that is good language practice too!

If you'd like to do an episode the cleaned-up subtitle files for episodes 15 through 20 are in the repo and you can pick one to work on. Since the videos contain two episodes each the numbering is slightly confusing. So the original video file called "Episode 8" ends up as episodes 15 and 16 here.

Does that sound like something you'd want to help with?

Marakai commented 4 years ago

I'm a devops guy, so this to me screams out for automation! SK is my big target for immersion - from what I've seen the show is hilarious and they avoid too much slang or slurred speech.

So, the ffmpeg is obviously easily scriptable. Does Rstudio have a CLI/API?

EDIT: Just saw that there is indeed a CLI and a whole scripting language underneath.

The Audacity part may be the hardest because at some point you still have to visually check and mark the extraction points. Wonder if there's cloud tools that could help with that.

gwmatthews commented 4 years ago

I agree about the series it is great for immersion and that's what I have been using it for too!

Automation would be nice for this project too, though as you mention the audio is the sticking point there. Maybe the way to speed things up would be to manually mark the cuts in the whole audio file and then use something like ffmpeg to extract segments into individual clips. The only issue there is that I tend to skip over those parts of the soundtrack with musical interludes and sound effects and just focus on the dialogue.

As for Rstudio I just use it as an IDE for some projects. In this case the R part of things (the scripting language) is more or less irrelevant. I just use Rstudio as a front end for pandoc which is what it relies on to convert the markdown files into html files and then builds a static website from the html according to the specs in a yaml file. So it's really pretty simple to setup.

ETA: Apparently in Audacity you can add an extra "label track" which allows you to mark off regions of a file for multiple clip extraction, which would speed up the process a bit. I'll try it out. Not quite pure CLI automation, but still maybe more efficient.

Marakai commented 4 years ago

Ooof, that's where I utterly lack experience - I can barely glue two songs together in Audacity. See also my comment in Patreon.

gwmatthews commented 4 years ago

Honestly though, even if it is a bit labor intensive, it is also more immersion to listen to the audio track and cut sections out while reading through the subtitle text! The method I mentioned -- adding markers to what Audacity calls a "label track" and then mass exporting the clips does seem to work fairly well.