User:Zuhui//SI25/Prototyping/BASH

From XPUB & Lens-Based wiki
< User:Zuhui‎ | ‎ | SI25‎ | Prototyping

Scripts

Tuesday with Manetta 151024

yt-dlp

151024 yt-dlp

//go to directory I want to save the youtube file
$yt-dlp (video url)
//copy the name of the file
$ffmpeg -i (name of the file) (filename+filetype) //this will convert to filetype that I want to download

Stream segments

151024 stream segments

Vosk

151024 with Manetta

Vosk 2

251124 with Michael

Trial 1, with Adventure Time clip

$ yt-dlp "https://www.youtube.com/watch?v=qbsvZclUXh8" --write-info-json
$ mv *.info.json *.webm interview/
$ ffmpeg -i adventure.webm adventure.wav
$ vosk-transcriber -l en-us -i adventure.wav -t srt -o adventure.srt
$ ../py_script/srt2vtt.py adventure.srt adventure.vtt
$ chmod +x ../py_script/srt2vtt.py //if permission denied
$ ffmpeg -i adventure.wav adventure.mp3 //for html

↘︎it works

Trial 2, with Json to vtt

$ vosk-transcriber -l en-us -i adventure.wav -t json -o adventure.json
$ ../py_script/voskjson2vtt.py adventure.json adventure_words.vtt

↘︎doesn't work and it's vtt file problem → ok now it works, used wrong python file to make vtt out of json

Video subtitling

http://vimeo.com/1043091875 ▲original
- first create vtt file (json if necessary), running python files.
- put them together on html

<video src="liberty-loop.mp4" controls style="width: 50%" >
   <track src="liberty-loop_words.vtt" kind="subtitles" srclang="en" label="English" default>
</video>

-also can style the subtitle on either vtt file or html.

WEBVTT
STYLE
::cue {
   color: yellow;
   background: rgba(0, 0, 0, 0.7);
   font-size: 20px;
   font-family: Arial, sans-serif;
}
HTML CSS
<style>
   video {
   }
   ::cue {
     color: yellow;
     background: rgba(0, 0, 0, 0.7);
     font-size: 20px;
     font-family: "Courier New", monospace;
   }
 </style>

↘︎ subtitle created(language detection in eng)

Command line

pwd outputs the name of the current working directory.
ls lists all files and directories in the working directory.
cd switches you into the directory you specify.
mkdir creates a new directory in the working directory.
touch creates a new file inside the working directory.
cat show you immediately what's inside the file

Helper commands to make navigation easier:

clear clears the terminal
tab autocompletes the name of a file or directory
↑ and ↓ allow you to cycle through previous commands
ls -a lists all contents of a directory, including hidden files and directories
ls -l lists all contents in long format
ls -t orders files and directories by the time they were last modified
Multiple options can be used together, like ls -alt

From the command line, you can also copy, move, and remove files and directories:

cp copies files
mv moves and renames files
rm removes files
rm -r removes directories
rm -rf  adding -f removes all the files without having to confirm

Redirection + other commands are powerful when combined with redirection commands:

> redirects standard output of a command to a file, overwriting previous content.
>> redirects standard output of a command to a file, appending new content to old content.
< redirects standard input to a command.
| redirects standard output of a command to another command.
sort sorts lines of text alphabetically.
uniq filters duplicate, adjacent lines of text.
grep searches for a text pattern and outputs it.
sed searches for a text pattern, modifies it, and outputs it.