多年之前,就有为不带字幕的游戏视频配上字幕的想法。
7 [, H- @0 ?7 v0 W) v 但是当时条件不成熟,但是目前来看,条件似乎成熟了
8 {% H- I3 Y L$ \. V: u7 N
3 l6 L" g0 D+ Q# [+ U Whisper是openAI的开源语音识别软件。
% o5 d& v6 ~. g- J) m$ s; z, d 它有一个.net的版本,在这个版本的基础上进行少量修改,就能将游戏视频对应的字幕识别成srt格式。
, |% }) ~6 o6 I 之后,对这个srt文件再进行在线批量翻译之后,进行少量调整之后,汉化工作就完成了。
0 _( ]: r' m$ C! L0 e. I
% S2 Z- B+ Q2 t9 f- O) K# y 地址如下$ B) K: s* i6 g) R e; Z5 N
https://github.com/sandrohanea/whisper.net. v0 Z: \! c- g, N$ U& {
; I' q: k9 O9 t& E! Z1 F9 | n# S' z
& y# F/ ?) J5 j1 U+ {9 F$ \5 A 编译最好使用vs2022编译,否则在.net sdk版本上会出很多问题。/ a& J" U) Y! R( ~2 w
8 ~! B' _# T7 V' [1 C5 r) k/ }
编译好之后,有几个注意点
2 ], U, f- l m
) C! p& h) T, W$ F$ N( F* J <0>使用的模型文件修改为大模型,ggml-large.bin,用这个模型效果比较好。! b7 e% E; `" s
当然,所有时间也会比较多,估计转换一批文件需要几个甚至几十个小时。 . r; O1 `6 Y4 i9 `3 l1 Z/ E
2 G+ s4 l" C) v( P' N b4 _6 D
<1>Language要设定为"english"。
( r1 L, c/ K" Z& p
9 ~/ V4 L0 V3 ?/ ~' U) I7 _0 W- /* var builder = factory.CreateBuilder(). P7 L f3 o+ V
- .WithLanguage(opt.Language);*/
% }( x" b, |8 ~+ M3 S: Z - var builder = factory.CreateBuilder()
8 Y# Q3 R2 E& p8 w/ C - .WithLanguage("english");
复制代码
. k+ X, [! j$ [. u- K <2>缺省好像只支持Wav格式,而且是要16K采样率的,需要实现转换成这种格式,否则会出错。% i( t! L" t5 O" A2 Z7 [2 O
/ U7 ~, I# V! X3 i0 i E) C
<3>缺省只提供了一个例子wav文件的转换,需要改为批量形式。
], J7 D& J& r. d6 i! B (遍历某个目录中的所有文件)8 E2 Z1 N/ R: \% F' M7 ~- y
! {% [: n+ W9 c, J3 b: N( ^6 E <4>输出的文件,需要稍加整理,以符合srt格式 ]1 w$ V1 u. v; F+ Z" G
* w( w8 Q6 v% P4 ^5 b9 W 以下是一个Wav文件的控制台输出(幽魂开场动画), n8 P; B" r* t9 Z
[( A b% d7 ~* c1 T* Q3 c
- 6 D8 s' `9 Z9 H" H$ `1 t" G ?
- whisper_init_from_file_no_state: loading model from 'ggml-large.bin'
& [8 e' ?# i r7 _ m' d# L - whisper_model_load: loading model. T: f* j, X' l& k3 @# ~9 @# Q
- whisper_model_load: n_vocab = 51865
& h( ?8 Q/ d) R+ U- |8 C - whisper_model_load: n_audio_ctx = 1500
5 e8 ^# K" V% r& l - whisper_model_load: n_audio_state = 1280 M1 @: G9 O% v. L) e
- whisper_model_load: n_audio_head = 20* H k: |# s/ N& Z* }
- whisper_model_load: n_audio_layer = 32
, \+ `: M: l) J+ }9 p; w$ x - whisper_model_load: n_text_ctx = 4482 P. c% v9 d9 D2 B7 J4 L9 L7 s4 L, b
- whisper_model_load: n_text_state = 1280
2 j+ ^8 B, A6 O0 \: c5 N - whisper_model_load: n_text_head = 20: n) s% s: J# _- j$ T5 r- b8 q( g# b
- whisper_model_load: n_text_layer = 32 D$ c. R# S9 T) J- {: R
- whisper_model_load: n_mels = 80
% V2 @- v# k) l8 f! ` - whisper_model_load: ftype = 1
/ g' r8 k5 V0 D( H7 C) C3 A - whisper_model_load: qntvr = 0
6 z2 {4 F7 c3 v5 A% l0 \ - whisper_model_load: type = 51 h: A3 @& {; j8 y5 W ]2 i; \
- whisper_model_load: mem required = 3557.00 MB (+ 71.00 MB per decoder)0 _# J" W: x* b/ g
- whisper_model_load: adding 1608 extra tokens
' g6 I! b0 |: x$ W- y n - whisper_model_load: model ctx = 2951.27 MB/ G1 a* _3 N. a. U
- whisper_model_load: model size = 2950.66 MB" `2 k* o, Y* i3 v0 P" I
- whisper_init_state: kv self size = 70.00 MB& O N. V4 r8 V
- whisper_init_state: kv cross size = 234.38 MB! ?$ d7 F- r0 }1 r
- New Segment: 00:00:00 ==> 00:00:02.7600000 : (birds chirping)2 P" A6 w- K5 w- \! E; I
- New Segment: 00:00:03.6600000 ==> 00:00:05.9000000 : (exhaling)
! R: c W4 a5 B% h8 l9 J( g - New Segment: 00:00:05.9000000 ==> 00:00:08.6600000 : (birds chirping)+ l% {% d1 H5 g0 y0 P. G
- New Segment: 00:00:08.6600000 ==> 00:00:35.1200000 : (gun firing)
* g4 D- P7 j9 X; a) k' Y - New Segment: 00:00:36.1200000 ==> 00:00:38.5400000 : (gun firing)
2 W$ [' D3 p* u( v7 A6 D2 c - New Segment: 00:00:39.0600000 ==> 00:00:41.4800000 : (gun firing)! X; \( X. x1 m% d( B7 ?' Q- [
- New Segment: 00:00:41.4800000 ==> 00:00:49.4000000 : (tires screeching)
c3 Y, w. \$ A) j6 n% H" m% t# ^ - New Segment: 00:00:49.4000000 ==> 00:00:58.5800000 : (glass shattering)
& G- T% c$ x' H9 {5 ~ - New Segment: 00:00:58.5800000 ==> 00:01:07.7400000 : (singing in foreign language)
7 N% I2 d4 W g! h( I - New Segment: 00:01:07.7400000 ==> 00:01:11.5800000 : (singing in foreign language)$ C- |, p; _# h8 s5 H
- New Segment: 00:01:11.5800000 ==> 00:01:17 : (tires screeching)1 F8 l, y# H/ z7 x$ M9 ?
- New Segment: 00:01:17 ==> 00:01:24.8400000 : (singing in foreign language)
$ H# X0 w; E7 r0 { ] - New Segment: 00:01:24.8400000 ==> 00:01:28.6400000 : (panting)1 E! w9 ]4 L( X% M! q& I* a
- New Segment: 00:01:36.7800000 ==> 00:01:39.2000000 : (gun firing)4 ~$ Q! X2 q0 Z) c" q5 {
- New Segment: 00:01:39.2000000 ==> 00:01:43.4600000 : - Adrian.
7 f, u* g r2 f - New Segment: 00:01:43.4600000 ==> 00:01:45.6200000 : - Oh God.' U3 @& y" c# t& `
- New Segment: 00:01:45.6200000 ==> 00:01:48.2000000 : - What's the matter sweetheart?
6 j$ S& n7 J/ f/ M# r4 B9 b - New Segment: 00:01:48.2000000 ==> 00:01:50.4200000 : Oh.
' H6 \ S( A9 A5 F# P8 [ - New Segment: 00:01:50.4200000 ==> 00:01:53.4600000 : - Oh it's horrible.
! |6 M, W4 l z$ t% U. g8 x7 N - New Segment: 00:01:53.4600000 ==> 00:01:55.3000000 : - Shh.
2 v( m: J* g2 j# _. e - New Segment: 00:01:55.3000000 ==> 00:02:02.3400000 : It was just a bad dream.
$ m; s$ A- b6 N @4 S" k# j - New Segment: 00:02:05.4200000 ==> 00:02:09.8800000 : - You don't ever have to be afraid of anything.
1 d I c1 B' i7 k0 y* F8 b: R - New Segment: 00:02:09.8800000 ==> 00:02:12.8000000 : I'll always be here to protect you.
# c4 V# h- B& p, j! u% w3 S' _ - New Segment: 00:02:12.9200000 ==> 00:02:15.5000000 : (gentle music)% q& x! U9 C/ o& l
- New Segment: 00:02:16.4800000 ==> 00:02:19.0600000 : (gentle music), W8 K. M) k' l0 V8 z$ N: B; U
- New Segment: 00:02:19.0600000 ==> 00:02:21.6400000 : (gentle music)
; v- {- s8 @6 G$ B - New Segment: 00:02:21.6400000 ==> 00:02:24.2200000 : (gentle music)' y# p# u4 L( u( ~: ?! D
- New Segment: 00:02:24.5400000 ==> 00:02:27.1200000 : (gentle music). l. [6 i& k9 U& ~
- New Segment: 00:02:27.1200000 ==> 00:02:29.7000000 : (gentle music)
9 J" O# l, j; `- s8 A - New Segment: 00:02:29.7000000 ==> 00:02:33.1800000 : [Music]
" f+ u9 ?& E9 ^' U0 ~ -
复制代码 ) g, }8 U5 Z3 }2 y: o1 g u8 _
1 J" q0 Q- z$ m9 x |