jtwang commited on
Commit
4b9f926
1 Parent(s): c62fa39

Update src/utils.py

Browse files
Files changed (1) hide show
  1. src/utils.py +5 -3
src/utils.py CHANGED
@@ -52,7 +52,7 @@ def format_timestamp(seconds: float, always_include_hours: bool = False, fractio
52
 
53
 
54
  def write_txt(transcript: Iterator[dict], file: TextIO):
55
- converter = opencc.OpenCC('s2twp') #s2twp.json - 簡體到繁體(臺灣正體標準)並轉換爲臺灣常用詞彙
56
  for segment in transcript:
57
  segment_text = converter.convert(segment['text'].strip())
58
  print(segment_text, file=file, flush=True)
@@ -63,9 +63,11 @@ def write_vtt(transcript: Iterator[dict], file: TextIO,
63
  iterator = __subtitle_preprocessor_iterator(transcript, maxLineWidth, highlight_words)
64
 
65
  # print("WEBVTT\n", file=file)
 
66
 
67
  for segment in iterator:
68
- text = segment['text'].replace('-->', '->')
 
69
 
70
  print(
71
  # f"{format_timestamp(segment['start'])} --> {format_timestamp(segment['end'])}\n"
@@ -88,7 +90,7 @@ def write_srt(transcript: Iterator[dict], file: TextIO,
88
  write_srt(result["segments"], file=srt)
89
  """
90
  iterator = __subtitle_preprocessor_iterator(transcript, maxLineWidth, highlight_words)
91
- converter = opencc.OpenCC('s2twp') #s2twp.json - 簡體到繁體(臺灣正體標準)並轉換爲臺灣常用詞彙
92
 
93
  for i, segment in enumerate(iterator, start=1):
94
  segment_text = segment['text'].replace('-->', '->')
 
52
 
53
 
54
  def write_txt(transcript: Iterator[dict], file: TextIO):
55
+ converter = opencc.OpenCC('s2tw') #s2tw.json - 簡體到臺灣正體
56
  for segment in transcript:
57
  segment_text = converter.convert(segment['text'].strip())
58
  print(segment_text, file=file, flush=True)
 
63
  iterator = __subtitle_preprocessor_iterator(transcript, maxLineWidth, highlight_words)
64
 
65
  # print("WEBVTT\n", file=file)
66
+ converter = opencc.OpenCC('s2tw') #s2tw.json - 簡體到臺灣正體
67
 
68
  for segment in iterator:
69
+ segment_text = segment['text'].replace('-->', '->')
70
+ text = converter.convert(segment_text)
71
 
72
  print(
73
  # f"{format_timestamp(segment['start'])} --> {format_timestamp(segment['end'])}\n"
 
90
  write_srt(result["segments"], file=srt)
91
  """
92
  iterator = __subtitle_preprocessor_iterator(transcript, maxLineWidth, highlight_words)
93
+ converter = opencc.OpenCC('s2tw') #s2tw.json - 簡體到臺灣正體
94
 
95
  for i, segment in enumerate(iterator, start=1):
96
  segment_text = segment['text'].replace('-->', '->')