Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

chore: handle empty text when translate

Maranellof44d08df2b27
diff --git a/README.md b/README.md
index a0659c9a..8dc23016 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,10 @@
<div align="center">
- <img src="./docs/images/logo.png" alt="KrillinAI" height="100">
+ <img src="./docs/images/logo.png" alt="KrillinAI" height="90">
- # AI Audio&Video Translation and Dubbing Tool
-<p>Based on LLMs, professional-level translation, capable of generating both portrait and landscape formats, one-click deployment.</p>
+ # AI Audio&Video Translation and Dubbing Tool
- **English | [中文](./docs/README_zh.md)**
+ **[English](./README.md) | [简体中文](./docs/README_zh.md) |[日本語](./docs/README_jp.md)**
[![Discord](https://img.shields.io/badge/Discord-KrillinAI-blue)](https://discord.gg/7RUa4WuW)
[![Twitter](https://img.shields.io/badge/Twitter-KrillinAI-orange?logo=twitter)](https://x.com/KrillinAI)
@@ -14,27 +13,26 @@
</div>
-🚀 **Project Overview**
+## Overview
Krillin AI is a one-stop solution designed for users and developers seeking high-quality video processing. It provides an end-to-end workflow, from video download to the final product, ensuring every frame of your content is extraordinary.
-## Key Features and Functions:
-🎯 **One-Click Start**: There is no need for complicated environment configuration. Krillin AI supports automatic installation of dependencies, enabling you to quickly get started and put it into use immediately.
-📥 **Video Acquisition**: Integrated with yt-dlp, it can directly download videos via YouTube and Bilibili links, simplifying the process of material collection. You can also directly upload local videos.
-📜 **Subtitle Recognition and Translation**: It supports voice and large model services of mainstream providers such as OpenAI and Alibaba Cloud, as well as local models (continuous integration in progress).
-🧠 **Intelligent Subtitle Segmentation and Alignment**: Utilize self-developed algorithms to conduct intelligent segmentation and alignment of subtitles, getting rid of rigid sentence breaks.
-🔄 **Custom Vocabulary Replacement**: Support one-click replacement of vocabulary to adapt to the language style of specific fields.
-🌍 **Professional Translation**: The whole-paragraph translation engine ensures the consistency of context and semantic coherence.
-🎙️ **Dubbing and Voice Cloning**: You can choose the default male or female voice tones to generate video reading dubbing for the translated content, or upload local audio samples to clone voice tones for dubbing.
-📝 **Dubbing Alignment**: It can perform cross-language dubbing and also align with the original subtitles.
-🎬 **Video Composition**: With one click, compose horizontal and vertical videos with embedded subtitles. Subtitles that exceed the width limit will be processed automatically.
-
-## Language Support
-Input languages: Chinese, English, Japanese, German, Turkish supported (more languages being added)
-Translation languages: 56 languages supported, including English, Chinese, Russian, Spanish, French, etc.
+## Key Features:
+🎯 **One-Click Start** - Launch your workflow instantly
-## Interface Preview
-![ui preview](./docs/images/ui.jpg)
+📥 **Video download** - yt-dlp and local file uploading supported
+
+📜 **Precise Subtitles** - Whisper-powered high-accuracy recognition
+
+🧠 **Smart Segmentation** - LLM-based subtitle chunking & alignment
+
+🌍 **Professional Translation** - Paragraph-level translation for consistency
+
+🔄 **Term Replacement** - One-click domain-specific vocabulary swap
+
+🎙️ **Dubbing and Voice Cloning** - CosyVoice selected or cloning voices
+
+🎬 **Video Composition** - Auto-formatting for horizontal/vertical layouts
## Showcase
The following picture demonstrates the effect after the subtitle file, which was generated through a one-click operation after importing a 46-minute local video, was inserted into the track. There was no manual adjustment involved at all. There are no missing or overlapping subtitles, the sentence segmentation is natural, and the translation quality is also quite high.
@@ -59,7 +57,14 @@ https://github.com/user-attachments/assets/0b32fad3-c3ad-4b6a-abf0-0865f0dd2385
</tr>
</table>
-## Quick Start
+## 🌍 Language Support
+Input languages: Chinese, English, Japanese, German, Turkish supported (more languages being added)
+Translation languages: 56 languages supported, including English, Chinese, Russian, Spanish, French, etc.
+
+## Interface Preview
+![ui preview](./docs/images/ui.jpg)
+
+## 🚀 Quick Start
### Basic Steps
1. Download the executable file that matches your device system from the release and place it in an empty folder.
2. Create a `config` folder inside the folder, then create a `config.toml` file in the `config` folder. Copy the content from the `config-example.toml` file in the source code's `config` directory into `config.toml` and fill in your configuration information accordingly.
diff --git a/docs/README_jp.md b/docs/README_jp.md
new file mode 100644
index 00000000..b601ecdc
--- /dev/null
+++ b/docs/README_jp.md
@@ -0,0 +1,117 @@
+<div align="center">
+ <img src="./images/logo.png" alt="KrillinAI" height="100">
+
+ # AI動画翻訳・吹き替えツール(簡単デプロイ)
+
+**[English](../README.md) |[简体中文](../docs/README_zh.md)|[日本語](../docs/README_jp.md)**
+
+ [![Discord](https://img.shields.io/badge/Discord-KrillinAI-blue)](https://discord.gg/7RUa4WuW)
+ [![Twitter](https://img.shields.io/badge/Twitter-KrillinAI-orange?logo=twitter)](https://x.com/KrillinAI)
+[![哔哩哔哩](https://img.shields.io/badge/哔哩哔哩-KrillinAI-red?logo=bilibili)](https://space.bilibili.com/242124650)
+
+</div>
+
+🚀 **プロジェクト概要**
+
+KrillinAIは、動画ダウンロード、音声抽出、音声文字起こし、テキスト分割、翻訳、調整から、最終的に抖音、Bilibili、小红书、WeChat動画、Kwaiなどの主要プラットフォーム形式への合成まで、オールインワンソリューションを提供します。
+
+## 主な特徴と機能:
+🎯 **ワンクリック起動**:複雑な環境設定不要、依存関係を自動インストール
+📥 **動画取得**:yt-dlpダウンロードまたはローカルファイルアップロード対応
+📜 **高精度認識**:Whisperベースの音声認識
+🧠 **インテリジェント分割**:LLMを使用した字幕分割と調整
+🔄 **用語置換**:専門分野の語彙をワンクリックで置換
+🌍 **プロ翻訳**:LLMベースの段落単位翻訳で文脈一貫性を保持
+🎙️ **音声クローン**:デフォルト音声またはカスタム音声クローニング
+🎬 **動画合成**:縦横画面と字幕レイアウトを自動処理
+
+## 効果デモ
+下図は46分のローカル動画をインポートし、ワンクリック実行後に生成された字幕ファイルをトラックに追加した効果です。手動調整なしで、欠落・重複なく、自然な文節区切りと高品質な翻訳を実現。
+![調整効果](./images/alignment.png)
+
+<table>
+<tr>
+<td width="50%">
+
+### 字幕翻訳
+---
+https://github.com/user-attachments/assets/bba1ac0a-fe6b-4947-b58d-ba99306d0339
+
+</td>
+<td width="50%">
+
+
+
+### 配音
+---
+https://github.com/user-attachments/assets/0b32fad3-c3ad-4b6a-abf0-0865f0dd2385
+
+</td>
+</tr>
+</table>
+
+## 対応言語
+入力言語対応:中国語、英語、日本語、ドイツ語、トルコ語(随時追加中)
+
+翻訳言語対応:英語、中国語、ロシア語、スペイン語、フランス語など56言語
+
+## インターフェースプレビュー
+![インターフェースプレビュー](./images/ui.jpg)
+
+
+
+## クイックスタート
+### 基本手順
+1. [Release](https://github.com/krillinai/KrillinAI/releases)からお使いのデバイスに合った実行ファイルをダウンロードし、空のフォルダに配置
+2. フォルダ内に`config`フォルダを作成し、`config`フォルダ内に`config.toml`ファイルを作成、ソースコードの`config`ディレクトリにある`config-example.toml`ファイルの内容をコピーして貼り付け、設定情報を記入(OpenAIモデルを使いたいがキーの取得方法がわからない場合はグループに参加して無料で試用可能)
+3. 実行ファイルをダブルクリック、またはターミナルで実行してサービスを起動
+4. ブラウザを開き `http://127.0.0.1:8888`と入力して使用開始
+
+### macOSユーザー向け
+本ソフトウェアは署名されていないため、macOSで実行する場合、「基本手順」のファイル設定完了後、手動でアプリを信頼する必要があります。方法は以下の通り:
+1. ターミナルで実行ファイル(ファイル名がKrillinAI_1.0.0_macOS_arm64と仮定)があるディレクトリを開く
+2. 以下のコマンドを順に実行:
+ ```
+ sudo xattr -rd com.apple.quarantine ./KrillinAI_1.0.0_macOS_arm64
+ sudo chmod +x ./KrillinAI_1.0.0_macOS_arm64
+ ./KrillinAI_1.0.0_macOS_arm64
+ ```
+ これでサービスが起動します
+
+### Dockerデプロイ
+本プロジェクトはDockerデプロイをサポートしています。[Docker部署说明](./docker.md)を参照してください
+
+### Cookie設定説明(オプション)
+
+動画ダウンロードに失敗する場合
+
+ [Cookie 配置说明](./get_cookies.md) を参照してCookie情報を設定してください。
+
+### 設定ヘルプ(必読)
+最速で簡単な設定方法:
+* transcription_providerとllm_providerの両方にopenaiを選択すると、openai、local_model、aliyunの3つの設定項目でopenai.apikeyのみ記入すれば字幕翻訳が可能です。(app.proxy、model、openai.base_urlは状況に応じて記入)
+
+ローカル音声認識モデルを使用する設定方法(macOS未対応)(コスト、速度、品質を考慮した選択)
+* transcription_providerにfasterwhisper、llm_providerにopenaiを記入すると、openai、local_modelの2つの設定項目でopenai.apikeyとlocal_model.faster_whisperを記入するだけで字幕翻訳が可能で、ローカルモデルは自動ダウンロードされます。(app.proxyとopenai.base_urlは同上)
+
+以下の使用状況では、Alibaba Cloudの設定が必要です:
+* llm_providerにaliyunを記入した場合、Alibaba Cloudの大規模モデルサービスを使用するため、aliyun.bailian項目の設定が必要
+* transcription_providerにaliyunを記入した場合、またはタスク起動時に「吹き替え」機能を有効にした場合、Alibaba Cloudの音声サービスを使用するため、aliyun.speech項目の記入が必要
+* 「吹き替え」機能を有効にし、ローカルオーディオを音声クローニング用にアップロードした場合、Alibaba CloudのOSSクラウドストレージサービスを使用するため、aliyun.oss項目の記入が必要
+Alibaba Cloud設定ヘルプ:[阿里云配置说明](./aliyun.md)
+
+## よくある質問
+
+[よくある質問](./faq.md)をご覧ください
+
+## コントリビューション規範
+1. .vscode、.ideaなどの不要なファイルをコミットしないでください。.gitignoreを活用してフィルタリングしてください
+2. config.tomlをコミットせず、代わりにconfig-example.tomlを使用してコミットしてください
+
+## お問い合わせ
+1. QQグループに参加して質問にお答えします:754069680
+2. ソーシャルメディアアカウントBilibiliをフォローし、AI技術分野の高品質なコンテンツを毎日シェアしています
+
+## Star History
+
+[![Star History Chart](https://api.star-history.com/svg?repos=krillinai/KrillinAI&type=Date)](https://star-history.com/#krillinai/KrillinAI&Date)
diff --git a/docs/README_zh.md b/docs/README_zh.md
index 2b5354c9..46f7cc81 100644
--- a/docs/README_zh.md
+++ b/docs/README_zh.md
@@ -1,39 +1,36 @@
<div align="center">
- <img src="./images/logo.png" alt="KrillinAI" height="100">
+ <img src="./images/logo.png" alt="KrillinAI" height="90">
# 极简部署AI视频翻译配音工具
- <p>专业级翻译切割对齐,高质量声音克隆,一键生成横竖屏格式,适配抖音,哔哩哔哩,小红书,视频号,快手等主流平台</p>
-
- 中文|[English](../README.md)
+ **[English](../README.md)|[简体中文](../docs/README_zh.md)|[日本語](../docs/README_jp.md)**
[![QQ 群](https://img.shields.io/badge/QQ%20群-754069680-green?logo=tencent-qq)](https://jq.qq.com/?_wv=1027&k=754069680)
[![哔哩哔哩](https://img.shields.io/badge/哔哩哔哩-KrillinAI-red?logo=bilibili)](https://space.bilibili.com/242124650)
</div>
-🚀 **项目简介**
+ **项目简介**
KrillinAI提供了从视频下载,音频提取,音频转录,文本切割,翻译,对齐,到最终合成适配抖音,哔哩哔哩,小红书,视频号,快手等主流平台格式的一站式解决方案。
## 主要特点与功能:
-🎯 **一键启动**:无需复杂的环境配置,自动安装依赖,立即投入使用
-📥 **视频获取**:集成yt-dlp,直接通过YouTube,Bilibili链接下载视频,也可直接上传本地视频
-📜 **字幕识别和翻译**:支持OpenAI、阿里云等主流供应商的语音和大模型服务以及Faster Whisper本地模型(持续集成中)
-🧠 **智能字幕分割对齐**:自研算法对字幕进行智能分割和对齐,摆脱生硬的断句
-🔄 **自定义词汇替换**:支持一键替换词汇,适应特定领域语言风格
-🌍 **专业级翻译**:整段翻译引擎,确保上下文一致和语义连贯
-🎙️ **配音和声音克隆**:可选默认的男女生音色生成翻译后的视频朗读配音,或者上传本地音频样本克隆音色进行朗读
-📝 **配音对齐**:跨语言配音,也能与原字幕对齐
-🎬 **视频合成**:一键合成横屏和竖屏视频,自动处理宽度超限的字幕
+🎯 **一键启动**:无需复杂的环境配置,自动安装依赖,立即投入使用
-## 语言支持
-输入语言支持:中文,英文,日语,德语,土耳其语(持续增加中)
+📥 **视频获取**:支持yt-dlp下载或本地文件上传
-翻译语言支持:英文,中文,俄语,西班牙语,法语等56种语言
+📜 **精准识别**:基于Whisper的高准确度语音识别
+
+🧠 **智能分段**:使用LLM进行字幕分段和对齐
+
+🔄 **术语替换**:一键替换专业领域词汇
+
+🌍 **专业翻译**:基于LLM,段落级翻译保持语义连贯性
+
+🎙️ **配音克隆**:提供CosyVoice精选音色或自定义音色克隆
+
+🎬 **视频合成**:自动处理横竖版视频和字幕排版
-## 界面预览
-![界面预览](./images/ui.jpg)
## 效果展示
下图为46分钟的本地视频导入,一键执行后生成的字幕文件入轨后的效果,无任何手动调整。无缺失、重叠,断句自然,翻译质量也非常高。
@@ -60,7 +57,17 @@ https://github.com/user-attachments/assets/0b32fad3-c3ad-4b6a-abf0-0865f0dd2385
</tr>
</table>
-## 快速开始
+
+## 语言支持
+输入语言支持:中文,英文,日语,德语,土耳其语(持续增加中)
+
+翻译语言支持:英文,中文,俄语,西班牙语,法语等56种语言
+
+## 界面预览
+![界面预览](./images/ui.jpg)
+
+
+## 🚀 快速开始
### 基本步骤
1. 下载[Release](https://github.com/krillinai/KrillinAI/releases)中与你设备系统匹配的可执行文件,放入空文件夹
2. 在文件夹内创建`config`文件夹,然后在`config`文件夹创建`config.toml`文件,复制源代码`config`目录下的`config-example.toml`文件的内容填入`config.toml`,并对照填写你的配置信息。(想用openai模型但不会获取key的可以加群免费试用)
diff --git a/internal/service/audio2subtitle.go b/internal/service/audio2subtitle.go
index e062ccff..7eee2c96 100644
--- a/internal/service/audio2subtitle.go
+++ b/internal/service/audio2subtitle.go
@@ -14,8 +14,8 @@ import (
"os"
"os/exec"
"path/filepath"
- "strconv"
"runtime/debug"
+ "strconv"
"strings"
"sync"
@@ -829,30 +829,31 @@ func (s Service) splitTextAndTranslate(taskId, baseTaskPath string, targetLangua
splitPrompt = fmt.Sprintf(types.SplitTextPrompt, types.GetStandardLanguageName(targetLanguage))
}
if audioFile.TranscriptionData.Text == "" {
- return fmt.Errorf("audioToSubtitle splitTextAndTranslate audioFile.TranscriptionData.Text is empty")
- }
- // 最多尝试4次获取有效的翻译结果
- for i := 0; i < 4; i++ {
- splitContent, err = s.ChatCompleter.ChatCompletion(splitPrompt + audioFile.TranscriptionData.Text)
- if err != nil {
- log.GetLogger().Warn("audioToSubtitle splitTextAndTranslate ChatCompletion error, retrying...",
- zap.Any("taskId", taskId), zap.Int("attempt", i+1), zap.Error(err))
- continue
- }
+ splitContent = ""
+ } else {
+ // 最多尝试4次获取有效的翻译结果
+ for i := 0; i < 4; i++ {
+ splitContent, err = s.ChatCompleter.ChatCompletion(splitPrompt + audioFile.TranscriptionData.Text)
+ if err != nil {
+ log.GetLogger().Warn("audioToSubtitle splitTextAndTranslate ChatCompletion error, retrying...",
+ zap.Any("taskId", taskId), zap.Int("attempt", i+1), zap.Error(err))
+ continue
+ }
- // 验证返回内容的格式和原文匹配度
- if isValidSplitContent(splitContent, audioFile.TranscriptionData.Text) {
- break
- }
+ // 验证返回内容的格式和原文匹配度
+ if isValidSplitContent(splitContent, audioFile.TranscriptionData.Text) {
+ break
+ }
- log.GetLogger().Warn("audioToSubtitle splitTextAndTranslate invalid response format or content mismatch, retrying...",
- zap.Any("taskId", taskId), zap.Int("attempt", i+1))
- err = fmt.Errorf("invalid split content format or content mismatch")
- }
+ log.GetLogger().Warn("audioToSubtitle splitTextAndTranslate invalid response format or content mismatch, retrying...",
+ zap.Any("taskId", taskId), zap.Int("attempt", i+1))
+ err = fmt.Errorf("invalid split content format or content mismatch")
+ }
- if err != nil {
- log.GetLogger().Error("audioToSubtitle splitTextAndTranslate failed after retries", zap.Any("taskId", taskId), zap.Error(err))
- return fmt.Errorf("audioToSubtitle splitTextAndTranslate error: %w", err)
+ if err != nil {
+ log.GetLogger().Error("audioToSubtitle splitTextAndTranslate failed after retries", zap.Any("taskId", taskId), zap.Error(err))
+ return fmt.Errorf("audioToSubtitle splitTextAndTranslate error: %w", err)
+ }
}
// 保存不带时间戳的原始字幕