{"id":31532844,"url":"https://github.com/hungdev/ebook-to-mp3","last_synced_at":"2025-10-04T03:59:40.638Z","repository":{"id":315936594,"uuid":"1061317674","full_name":"hungdev/ebook-to-mp3","owner":"hungdev","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-21T17:16:16.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-21T19:20:58.410Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hungdev.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-21T17:14:34.000Z","updated_at":"2025-09-21T17:16:19.000Z","dependencies_parsed_at":"2025-09-21T19:21:59.508Z","dependency_job_id":"ae8062f8-349b-47fe-89c0-3cb9140c888f","html_url":"https://github.com/hungdev/ebook-to-mp3","commit_stats":null,"previous_names":["hungdev/ebook-to-mp3"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/hungdev/ebook-to-mp3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungdev%2Febook-to-mp3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungdev%2Febook-to-mp3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungdev%2Febook-to-mp3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungdev%2Febook-to-mp3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hungdev","download_url":"https://codeload.github.com/hungdev/ebook-to-mp3/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungdev%2Febook-to-mp3/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278262438,"owners_count":25957938,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-04T03:59:39.169Z","updated_at":"2025-10-04T03:59:40.634Z","avatar_url":"https://github.com/hungdev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ebook to MP3\n\nCông cụ dòng lệnh chuyển ebook tiếng Việt (.txt hoặc .epub) thành file MP3 bằng giọng đọc tự nhiên. Hỗ trợ:\n\n- `say` (giọng hệ thống macOS, gồm Siri Voice, Linh, v.v.).\n- `gTTS` (Google Text-to-Speech, cần kết nối Internet).\n- Tách ebook thành nhiều file theo chương hoặc theo thời lượng mong muốn.\n\n## Yêu cầu\n\n- Python 3.9+.\n- macOS để dùng engine `say`.\n- Internet và thư viện `gTTS` khi dùng engine `gtts`:\n  ```bash\n  pip install gTTS\n  ```\n- Nếu xuất MP3 bằng `say`, nên có `ffmpeg` hoặc đảm bảo `afconvert` hỗ trợ MP3.\n\n## Cách sử dụng cơ bản\n\n```bash\npython3 ebook_to_mp3.py \u003cinput\u003e \u003coutput.mp3\u003e [tùy chọn]\n```\n\nVí dụ nhanh với gTTS:\n\n```bash\npython3 ebook_to_mp3.py text.txt text.mp3 --engine gtts\n```\n\nVí dụ dùng giọng Siri trên macOS:\n\n```bash\npython3 ebook_to_mp3.py ebook.txt ebook.mp3 --engine say --voice \"Siri (Vietnamese (Voice 1))\" --rate 170\n```\n\nLiệt kê các giọng `say` có sẵn:\n\n```bash\npython3 ebook_to_mp3.py --engine say --list-voices\n```\n\n## Chia nhỏ ebook\n\n### Theo chương\n\n- EPUB: chương được lấy tự động từ từng file `.xhtml`/`.html`.\n- TXT: cung cấp regex nhận diện tiêu đề chương, ví dụ nếu mỗi chương bắt đầu bằng \"Chương 1\", \"Chương 2\"…\n\n```bash\npython3 ebook_to_mp3.py novel.txt output.mp3 \\\n  --engine gtts \\\n  --split-mode sections \\\n  --split-marker \"^Chương\\\\s+\\\\d+\"\n```\n\nCác file sẽ được tạo thành `output_001.mp3`, `output_002.mp3`, …\n\n### Theo thời lượng ước lượng\n\nScript ước lượng số từ dựa trên tốc độ đọc (`--words-per-minute`, mặc định 160 wpm) và tách thành các đoạn gần với thời lượng yêu cầu.\n\n```bash\npython3 ebook_to_mp3.py book.epub book.mp3 \\\n --engine gtts \\\n --split-mode duration \\\n --target-seconds 900 \\\n --words-per-minute 238\n\n```\n\n## Tùy chọn quan trọng\n\n| Tham số                                 | Mô tả                                                             |\n| --------------------------------------- | ----------------------------------------------------------------- |\n| `--engine {say,gtts}`                   | Chọn bộ tổng hợp giọng (mặc định `say`).                          |\n| `--voice`                               | Tên giọng dùng cho `say` (ví dụ `\"Siri (Vietnamese (Voice 1))\"`). |\n| `--rate`                                | Tốc độ đọc (từ/phút) với engine `say`.                            |\n| `--prefer`                              | Thứ tự ưu tiên khi chuyển AIFF sang MP3 (`ffmpeg`, `afconvert`).  |\n| `--split-mode {none,sections,duration}` | Cơ chế tách thành nhiều file.                                     |\n| `--split-marker`                        | Regex đánh dấu chương cho file TXT khi dùng `sections`.           |\n| `--target-seconds`                      | Thời lượng mục tiêu mỗi file khi dùng `duration`.                 |\n| `--words-per-minute`                    | Tốc độ đọc ước lượng để tính thời lượng (mặc định 160).           |\n\n## Ghi chú\n\n- Engine `gtts` cần Internet; nếu mất kết nối, script hủy file MP3 dở dang và báo lỗi.\n- Các file MP3 đầu ra sẽ được đặt trong cùng thư mục với `output` đã chỉ định.\n- Khi tách nhiều phần, `output` được hiểu là tiền tố; ví dụ `audiobook.mp3` -\u003e `audiobook_001.mp3`, `audiobook_002.mp3`...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhungdev%2Febook-to-mp3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhungdev%2Febook-to-mp3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhungdev%2Febook-to-mp3/lists"}