Skip to content

Commit

Permalink
Merge pull request #266 from Huanshere/new_tts
Browse files Browse the repository at this point in the history
v2.0 New tts
  • Loading branch information
Huanshere authored Nov 17, 2024
2 parents d49bca2 + 74638fd commit 495e407
Show file tree
Hide file tree
Showing 45 changed files with 2,016 additions and 1,116 deletions.
55 changes: 0 additions & 55 deletions .github/ISSUE_TEMPLATE/issue-report.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,5 @@ config.backup.yaml

# runtime
runtime/
dev/
dev/
installer_files/
67 changes: 67 additions & 0 deletions OneKeyInstall&Start.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
@echo off

cd /D "%~dp0"

set PATH=%PATH%;%SystemRoot%\system32

echo "%CD%"| findstr /C:" " >nul && echo This script relies on Miniconda which can not be silently installed under a path with spaces. && goto end

@rem fix failed install when installing to a separate drive
set TMP=%cd%\installer_files
set TEMP=%cd%\installer_files

@rem config
set INSTALL_DIR=%cd%\installer_files
set CONDA_ROOT_PREFIX=%cd%\installer_files\conda
set INSTALL_ENV_DIR=%cd%\installer_files\env
set MINICONDA_DOWNLOAD_URL=https://repo.anaconda.com/miniconda/Miniconda3-py310_23.1.0-1-Windows-x86_64.exe
set conda_exists=F

@rem figure out whether git and conda needs to be installed
call "%CONDA_ROOT_PREFIX%\_conda.exe" --version >nul 2>&1
if "%ERRORLEVEL%" EQU "0" set conda_exists=T

@rem (if necessary) install git and conda into a contained environment
@rem download conda
if "%conda_exists%" == "F" (
echo Downloading Miniconda from %MINICONDA_DOWNLOAD_URL% to %INSTALL_DIR%\miniconda_installer.exe

mkdir "%INSTALL_DIR%"
call curl -Lk "%MINICONDA_DOWNLOAD_URL%" > "%INSTALL_DIR%\miniconda_installer.exe" || ( echo. && echo Miniconda failed to download. && goto end )

echo Installing Miniconda to %CONDA_ROOT_PREFIX%
start /wait "" "%INSTALL_DIR%\miniconda_installer.exe" /InstallationType=JustMe /NoShortcuts=1 /AddToPath=0 /RegisterPython=0 /NoRegistry=1 /S /D=%CONDA_ROOT_PREFIX%

@rem test the conda binary
echo Miniconda version:
call "%CONDA_ROOT_PREFIX%\_conda.exe" --version || ( echo. && echo Miniconda not found. && goto end )
)

@rem create the installer env
if not exist "%INSTALL_ENV_DIR%" (
echo Packages to install: python=3.10.0 requests rich ruamel.yaml
call "%CONDA_ROOT_PREFIX%\_conda.exe" create --no-shortcuts -y -k --prefix "%INSTALL_ENV_DIR%" python=3.10.0 requests rich "ruamel.yaml" || ( echo. && echo Conda environment creation failed. && goto end )
)

@rem check if conda environment was actually created
if not exist "%INSTALL_ENV_DIR%\python.exe" ( echo. && echo Conda environment is empty. && goto end )

@rem environment isolation
set PYTHONNOUSERSITE=1
set PYTHONPATH=
set PYTHONHOME=
@rem ! may cause error if we use cudnn on windows
set "CUDA_PATH=%INSTALL_ENV_DIR%"
set "CUDA_HOME=%CUDA_PATH%"

@rem activate installer env
call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%" || ( echo. && echo Miniconda hook not found. && goto end )

@rem Run pip setup
call python pip_setup.py

echo.
echo Done!

:end
pause
13 changes: 0 additions & 13 deletions OneKeyStart.bat

This file was deleted.

32 changes: 21 additions & 11 deletions batch/OneKeyBatch.bat
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
@echo off
cd /d %~dp0..

if exist runtime (
echo Using runtime folder...
runtime\python.exe batch\utils\batch_processor.py
) else (
echo Runtime folder not found. Using conda environment...
call conda activate videolingo
python batch\utils\batch_processor.py
call conda deactivate
)
cd /D "%~dp0"
cd ..

@rem 设置环境变量
set INSTALL_DIR=%cd%\installer_files
set CONDA_ROOT_PREFIX=%cd%\installer_files\conda
set INSTALL_ENV_DIR=%cd%\installer_files\env

@rem 环境隔离设置
set PYTHONNOUSERSITE=1
set PYTHONPATH=
set PYTHONHOME=
set "CUDA_PATH=%INSTALL_ENV_DIR%"
set "CUDA_HOME=%CUDA_PATH%"

@rem 激活conda环境
call "%CONDA_ROOT_PREFIX%\condabin\conda.bat" activate "%INSTALL_ENV_DIR%" || ( echo. && echo Conda environment not found && goto end )

@rem 运行批处理脚本
call python batch\utils\batch_processor.py

:end
pause
41 changes: 19 additions & 22 deletions batch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,27 @@

[English](./README.md) | [简体中文](./README.zh.md)

Before utilizing the batch mode, ensure you have familiarized yourself with the Streamlit mode and properly configured the parameters in `config.yaml`.
Before utilizing the batch mode, ensure you have used the Streamlit mode and properly configured the parameters in `config.yaml`.

## Usage Guide

> Note: All referenced files, with the exception of `config.yaml`, are located within the `batch` folder.
### 1. Video File Preparation

- Upload your video files for processing to the `input` folder
- YouTube links can be specified in the subsequent step
- Place your video files in the `input` folder
- YouTube links can be specified in the next step

### 2. Task Configuration

Modify the `tasks_setting.xlsx` file as follows:
Edit the `tasks_setting.xlsx` file:

| Field | Description | Acceptable Values |
|-------|-------------|-------------------|
| Video File | Video filename (excluding `input/` prefix) or YouTube URL | - |
| Source Language | Original language of the video | 'en', 'zh', 'auto', or leave empty for default |
| Target Language | Desired translation language | Use natural language description, or leave empty for default |
| Dubbing | Enable or disable dubbing | 0 or empty: no dubbing; 1: enable dubbing |
| Video File | Video filename (without `input/` prefix) or YouTube URL | - |
| Source Language | Source language | 'en', 'zh', ... or leave empty for default |
| Target Language | Translation language | Use natural language description, or leave empty for default |
| Dubbing | Enable dubbing | 0 or empty: no dubbing; 1: enable dubbing |

Example configuration:
Example:

| Video File | Source Language | Target Language | Dubbing |
|------------|-----------------|-----------------|---------|
Expand All @@ -33,24 +31,23 @@ Example configuration:

### 3. Executing Batch Processing

1. Launch `OneKeyBatch.bat` with a double-click
2. Processed files will be stored in the `output` folder
3. Monitor task progress in the `Status` column of `tasks_setting.xlsx`
1. Double-click to run `OneKeyBatch.bat`
2. Output files will be saved in the `output` folder
3. Task status can be monitored in the `Status` column of `tasks_setting.xlsx`

> Note: Keep `tasks_setting.xlsx` closed during execution to prevent interruptions due to file access conflicts.

## Important Considerations

### Handling Interruptions

In the event of an unexpected command line closure, language settings in `config.yaml` may be altered. Verify these settings before attempting to resume processing.
If the command line is closed unexpectedly, language settings in `config.yaml` may be altered. Check settings before retrying.

### Error Management

- Files that fail to process will be relocated to the `output/ERROR` folder
- Detailed error messages are logged in the `Status` column of `tasks_setting.xlsx`
- To reattempt processing:
1. Transfer the specific video folder from `ERROR` to the root directory
2. Rename this folder to `output`
3. Utilize the Streamlit mode to reinitiate processing
- Failed files will be moved to the `output/ERROR` folder
- Error messages are recorded in the `Status` column of `tasks_setting.xlsx`
- To retry:
1. Move the single video folder from `ERROR` to the root directory
2. Rename it to `output`
3. Use Streamlit mode to process again
4 changes: 1 addition & 3 deletions batch/README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

## 使用方法

> 注:以下所说文件除了 `config.yaml` 以外都在 `batch` 文件夹下。
### 1. 准备视频文件

- 将要处理的视频文件放入 `input` 文件夹
Expand All @@ -20,7 +18,7 @@
| 字段 | 说明 | 可选值 |
|------|------|--------|
| Video File | 视频文件名(无需 `input/` 前缀)或 YouTube 链接 | - |
| Source Language | 源语言 | 'en', 'zh', 'auto',或留空使用默认设置 |
| Source Language | 源语言 | 'en', 'zh', ... 或留空使用默认设置 |
| Target Language | 翻译语言 | 使用自然语言描述,或留空使用默认设置 |
| Dubbing | 是否配音 | 0 或留空:不配音;1:配音 |

Expand Down
19 changes: 10 additions & 9 deletions batch/utils/settings_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@
from rich.console import Console
from rich.panel import Panel

# Constants
SETTINGS_FILE = 'batch/tasks_setting.xlsx'
INPUT_FOLDER = os.path.join('batch', 'input')
VALID_DUBBING_VALUES = [0, 1]

console = Console()

def check_settings():
df = pd.read_excel('batch/tasks_setting.xlsx')
input_files = set(os.listdir(os.path.join('batch', 'input')))
os.makedirs(INPUT_FOLDER, exist_ok=True)
df = pd.read_excel(SETTINGS_FILE)
input_files = set(os.listdir(INPUT_FOLDER))
excel_files = set(df['Video File'].tolist())
files_not_in_excel = input_files - excel_files

Expand All @@ -31,19 +37,14 @@ def check_settings():

if video_file.startswith('http'):
url_tasks += 1
elif os.path.isfile(os.path.join('batch', 'input', video_file)):
elif os.path.isfile(os.path.join(INPUT_FOLDER, video_file)):
local_video_tasks += 1
else:
console.print(Panel(f"Invalid video file or URL 「{video_file}」", title=f"[bold red]Error in row {index + 2}", expand=False))
all_passed = False

if not pd.isna(source_language):
if source_language.lower() not in ['en', 'zh', 'auto']:
console.print(Panel(f"Invalid source language 「{source_language}」", title=f"[bold red]Error in row {index + 2}", expand=False))
all_passed = False

if not pd.isna(dubbing):
if int(dubbing) not in [0, 1]:
if int(dubbing) not in VALID_DUBBING_VALUES:
console.print(Panel(f"Invalid dubbing value 「{dubbing}」", title=f"[bold red]Error in row {index + 2}", expand=False))
all_passed = False

Expand Down
Loading

0 comments on commit 495e407

Please sign in to comment.