★🔊📖

★経済学

◇経済 / 経済学

◇経済 / 経済学 / 理論

中国語書名 英語書名 著者 Book ID
国富論——国民の富の性質と原因についての研究 The Wealth of Nations
別名:An Inquiry into the Nature and Causes of the Wealth of Nations
(英)アダム・スミス Book 1-5

★軍事

◇軍事 / 軍事理論

中国語書名 英語書名 著者 Book ID
孫子兵法
別名:孫武兵法
The Art of War 孫武 Book 6

★政治

◇政治 / 政治小説

中国語書名 英語書名 著者 Book ID
一九八四 Nineteen Eighty-Four (英)ジョージ・オーウェル Book 7-9

★オーディオブック制作用スクリプト

◇YouTube動画のmp3をダウンロード

youtube-dl -x --audio-format mp3 --audio-quality 0 "https://www.youtube.com/watch?v=VIDEO_ID"
# yt_mp3_download.py
import subprocess

def download_youtube_mp3():
    yt_dlp_path = "/Users/dev/Library/Python/3.9/bin/yt-dlp"
    url = input("YouTube動画のリンクを入力してください:").strip()
    
    command = [
        yt_dlp_path,
        "-x",  # 音声を抽出
        "--audio-format", "mp3",  # mp3形式に変換
        url
    ]

    try:
        subprocess.run(command, check=True)
        print("✅ ダウンロード完了")
    except subprocess.CalledProcessError as e:
        print("❌ ダウンロード失敗:", e)

if __name__ == "__main__":
    download_youtube_mp3()

◇各章ごとに音声を分割

# split_audio.py
import os
import subprocess

input_file = "/Users/dev/Downloads/aaa/xxx.mp3"
output_dir = "output_chapters"
os.makedirs(output_dir, exist_ok=True)

chapters = [
    ("a0", "00:00:00"),
    ("1-chapter1", "00:00:09"),
    ("1-chapter2", "00:39:31"),
    ("2-chapter1", "03:35:20"),
    ("2-chapter2", "04:00:13"),
    ("3-chapter1", "07:48:41"),
    ("3-chapter2", "08:18:27")
]

for i in range(len(chapters)):
    title, start = chapters[i]
    end = chapters[i+1][1] if i+1 < len(chapters) else None

    output_file = os.path.join(output_dir, f"{title}.mp3")
    cmd = ["ffmpeg", "-y", "-i", input_file, "-ss", start]
    if end:
        cmd += ["-to", end]
    cmd += ["-c", "copy", output_file]

    subprocess.run(cmd)
    print(f"出力完了: {output_file}")

print("すべての章を正常に分割しました。")

◇音声を結合

# merge_audio.py
from pydub import AudioSegment
import os

# 音声ファイルのディレクトリを設定
audio_dir = "/Users/dev/Downloads/aaa/irodori-mp3/X_audio_all"
# すべての mp3 ファイルを取得し、ファイル名でソート(任意)
audio_files = sorted([f for f in os.listdir(audio_dir) if f.endswith(".mp3")])

# 空のオーディオオブジェクトを作成
combined = AudioSegment.empty()

# 各音声ファイルを順に追加
for file in audio_files:
    file_path = os.path.join(audio_dir, file)
    audio = AudioSegment.from_mp3(file_path)
    combined += audio
    print(f"追加済み: {file}")

# 結合された音声を出力
output_path = os.path.join(audio_dir, "combined_output.mp3")
combined.export(output_path, format="mp3")
print(f"結合完了、保存先: {output_path}")