Skip to content

Instantly share code, notes, and snippets.

View daitomanabe's full-sized avatar

Daito Manabe daitomanabe

View GitHub Profile
@daitomanabe
daitomanabe / gist:32eb4679b72c023be8fae1af3f2f7c55
Created June 25, 2023 13:47
This script demonstrates how to use the `say` command in macOS to generate sound files from a text file, with each word on a separate line.
while IFS= read -r line; do echo "$line" | say -o "${line}.aiff"; done < input.txt
@daitomanabe
daitomanabe / combine_csv.py
Created June 4, 2023 08:03
combine and vis csv
import os
import argparse
import pandas as pd
import matplotlib.pyplot as plt
from datetime import datetime
# コマンドライン引数のパーサーを作成
parser = argparse.ArgumentParser(description='CSVファイルの結合')
parser.add_argument('input_dir', type=str, help='入力ディレクトリのパス')
parser.add_argument('output_file', type=str, help='出力ファイルの名前')
@daitomanabe
daitomanabe / midi_to_csv.py
Last active June 4, 2023 04:30
midi_to_csv.py
import mido
import pandas as pd
import argparse
import os
from collections import defaultdict
def midi_to_csv(midi_path, bpm):
mid = mido.MidiFile(midi_path)
active_notes = defaultdict(int)
import csv
from bvh import Bvh
with open('your_file.bvh') as f:
mocap = Bvh(f.read())
with open('output.csv', 'w', newline='') as f:
writer = csv.writer(f)
writer.writerow(['Frame', 'Rotation_X', 'Rotation_Y', 'Rotation_Z'])
import os
import sys
from moviepy.editor import VideoFileClip
from PIL import Image
# Directory containing the .mov files to be converted
input_dir = sys.argv[1]
# Base directory for outputting the image files
output_base_dir = sys.argv[2]
@daitomanabe
daitomanabe / wav_to_csv.py
Created June 1, 2023 12:16
wav_to_csv (low, mid, high, total)
import numpy as np
import soundfile as sf
import csv
import os
import sys
import glob
# Directory is passed as a command-line argument
directory = sys.argv[1]
@daitomanabe
daitomanabe / extract_channels.py
Last active May 31, 2023 08:22
extract_channels
from pydub import AudioSegment
import sys
import os
def extract_channels(input_file, output_dir):
audio = AudioSegment.from_file(input_file, format="wav")
# Check if the audio is already mono
if audio.channels == 1:
print(f"Ignoring file '{input_file}' as it is already mono")
@daitomanabe
daitomanabe / random_clip_extractor.py
Last active June 1, 2023 12:17
random_clip_extractor
import argparse
import random
from moviepy.video.io.VideoFileClip import VideoFileClip
import os
import concurrent.futures
def write_clip(clip, start_time, end_time, output_file_path):
output_clip = clip.subclip(start_time, end_time)
output_clip.write_videofile(output_file_path, codec='libx264', bitrate='5000k')
print(f'Created: {output_file_path}')
@daitomanabe
daitomanabe / video_splitter.py
Last active June 9, 2023 00:09
video_splitter
import argparse
import os
import datetime
import math
from moviepy.editor import VideoFileClip
def split_video(video_file, output_basename, bpm, first_clip_length=None, offset_4bar=None):
# Load the video file
video = VideoFileClip(video_file)
@daitomanabe
daitomanabe / install virtualenv ubuntu 16.04.md
Created November 14, 2022 09:30 — forked from frfahim/install virtualenv ubuntu 16.04.md
How to install virtual environment on ubuntu 16.04

How to install virtualenv:

Install pip first

sudo apt-get install python3-pip

Then install virtualenv using pip3

sudo pip3 install virtualenv