Skip to content

Commit c7d84d2

Browse files
authored
refactor: adjust environment (#128)
1 parent 20ddafd commit c7d84d2

File tree

5 files changed

+7
-14
lines changed

5 files changed

+7
-14
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ graph TD
8686
8787
### Installation(有 GPU 版本)
8888

89-
> 是否有 GPU 以 `nvidia-smi` 显示驱动以及 `CUDA` 检查通过为准。如果未配置显卡驱动或未安装 `CUDA`,即使有 GPU 也无法使用。
89+
> 是否有 GPU 以 `nvidia-smi` 显示 nvidia GPU 驱动以及 `nvcc -V` 显示 `CUDA` 版本号为准。如果未配置显卡驱动或未安装 `CUDA`,即使有 GPU 也无法使用,而会使用 CPU 推理(不推荐,可根据自身硬件条件判断是否尝试 CPU 推理)
9090
9191
> [!TIP]
9292
> 如果你是 windows 用户,请不要使用命令提示符(Command Prompt)或 Windows PowerShell,请使用 [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.4) 或 WSL 或 **Git Bash**(推荐)。
@@ -178,7 +178,7 @@ logs # 日志文件夹
178178
### Installation(无 GPU 版本)
179179
无 GPU 版本过程基本同上,可以跳过步骤 3,需要注意在执行步骤 5 **之前**完成以下设置将确保完全用 CPU 渲染视频弹幕。
180180

181-
1. 请将 `src/allconfig.py` 文件中的 `GPU_EXIST` 参数设置为 `False`
181+
1. 请将 `src/allconfig.py` 文件中的 `GPU_EXIST` 参数设置为 `False`。(若不置为 `False` 且则会使用 CPU 推理,不推荐,可自行根据硬件条件进行尝试。)
182182
2.`MODEL_TYPE` 调整为 `merge` 或者 `append`
183183

184184
> [!TIP]

docs/installation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
## Installation(有 GPU 版本)
1616

17-
> 是否有 GPU 以 `nvidia-smi` 显示驱动以及 `CUDA` 检查通过为准。如果未配置显卡驱动或未安装 `CUDA`,即使有 GPU 也无法使用。
17+
> 是否有 GPU 以 `nvidia-smi` 显示 nvidia GPU 驱动以及 `nvcc -V` 显示 `CUDA` 版本号为准。如果未配置显卡驱动或未安装 `CUDA`,即使有 GPU 也无法使用,而会使用 CPU 推理(不推荐,可根据自身硬件条件判断是否尝试 CPU 推理)
1818
1919
> [!TIP]
2020
> 如果你是 windows 用户,请不要使用命令提示符(Command Prompt)或 Windows PowerShell,请使用 [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.4) 或 WSL 或 **Git Bash**(推荐)。
@@ -107,5 +107,5 @@ logs # 日志文件夹
107107
## Installation(无 GPU 版本)
108108
无 GPU 版本过程基本同上,可以跳过步骤 3,需要注意在执行步骤 5 **之前**完成以下设置将确保完全用 CPU 渲染视频弹幕。
109109

110-
1. 请将 `src/allconfig.py` 文件中的 `GPU_EXIST` 参数设置为 `False`
110+
1. 请将 `src/allconfig.py` 文件中的 `GPU_EXIST` 参数设置为 `False`。(若不置为 `False` 且则会使用 CPU 推理,不推荐,可自行根据硬件条件进行尝试。)
111111
2.`MODEL_TYPE` 调整为 `merge` 或者 `append`

src/subtitle/config.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ def init_settings_config():
4343

4444
init_settings_config()
4545

46-
ffmpeg_bin = os.path.join('linux_x64', 'ffmpeg')
47-
FFMPEG_PATH = os.path.join(BASE_DIR, '', ffmpeg_bin)
48-
os.chmod(FFMPEG_PATH, stat.S_IRWXU+stat.S_IRWXG+stat.S_IRWXO)
49-
5046
SILENCE_THRESH = -70 # silence below -70dBFS is considered silence
5147
MIN_SILENCE_LEN = 700 # if silence is longer than 700ms, split
5248
LENGTH_LIMIT = 60 * 1000 # split into segments no longer than 1 minute

src/subtitle/generate.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def __call__(self, region):
111111
start = max(0, start - self.include_before)
112112
end += self.include_after
113113
temp = tempfile.NamedTemporaryFile(suffix='.flac', delete=False)
114-
command = [config.FFMPEG_PATH, "-ss", str(start), "-t", str(end - start),
114+
command = ["ffmpeg", "-ss", str(start), "-t", str(end - start),
115115
"-y", "-i", self.source_path,
116116
"-loglevel", "error", temp.name]
117117
use_shell = True if os.name == "nt" else False
@@ -170,10 +170,7 @@ def extract_audio(self, rate=16000):
170170
if not os.path.isfile(self.filename):
171171
print("The given file does not exist: {}".format(self.filename))
172172
raise Exception("Invalid filepath: {}".format(self.filename))
173-
if not self.which(config.FFMPEG_PATH):
174-
print("ffmpeg: Executable not found on machine.")
175-
raise Exception("Dependency not found: ffmpeg")
176-
command = [config.FFMPEG_PATH, "-y", "-i", self.filename,
173+
command = ["ffmpeg", "-y", "-i", self.filename,
177174
"-ac", '1', "-ar", str(rate),
178175
"-loglevel", "error", temp.name]
179176
use_shell = True if os.name == "nt" else False
@@ -252,7 +249,7 @@ def run(self, output=None):
252249
"""
253250
audio_filename, audio_rate = self.extract_audio()
254251
regions = self.find_speech_regions(audio_filename)
255-
pool = multiprocessing.Pool(10)
252+
pool = multiprocessing.Pool(12)
256253
converter = FLACConverter(source_path=audio_filename)
257254
recognizer = AudioRecogniser(language=self.language)
258255
transcripts = []

src/subtitle/linux_x64/ffmpeg

-73.6 MB
Binary file not shown.

0 commit comments

Comments
 (0)