소스 검색

add zhconv convert

liqian 2 년 전
부모
커밋
f7ad259c72
2개의 변경된 파일10개의 추가작업 그리고 5개의 파일을 삭제
  1. 5 4
      requirements.txt
  2. 5 1
      whisper_asr.py

+ 5 - 4
requirements.txt

@@ -1,9 +1,10 @@
-moviepy==1.0.3
-pandas==1.1.3
-oss2==2.14.0
-openai_whisper==20230314
 pyodps==0.10.7
+moviepy==1.0.3
 requests==2.31.0
+openai_whisper==20230314
+zhconv==1.4.3
+oss2==2.14.0
+pandas==1.1.3
 aliyun_python_sdk==2.2.0
 odps==3.5.1
 whisper==1.1.10

+ 5 - 1
whisper_asr.py

@@ -1,10 +1,14 @@
 import whisper
+from zhconv import convert
 
 
 def get_whisper_asr(video, model='medium'):
     try:
         model = whisper.load_model(model)
         result = model.transcribe(video, language='Chinese')
-        return result['text']
+        # 简繁转换
+        # zh-cn 大陆简体
+        # zh-hant 繁体
+        return convert(result['text'], 'zh-cn')
     except:
         return ''