Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -93,12 +93,19 @@ def create_textfile(url, file, state):
|
|
93 |
file_path = os.getcwd() + "/" + file_name
|
94 |
|
95 |
else:
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
# 音声ファイルを分割
|
100 |
audio_list = audio_seg(file_path)
|
101 |
|
|
|
|
|
102 |
# whisperで文字に起こす
|
103 |
text_list = whisper_audio(client, audio_list, state["lang"])
|
104 |
|
@@ -132,12 +139,8 @@ def whisper_audio(client, audio_list, lang):
|
|
132 |
# ファイル名設定
|
133 |
text_name = audio.replace(".mp3",".txt")
|
134 |
|
135 |
-
print(text_name)
|
136 |
-
|
137 |
with open(text_name, mode="w") as f:
|
138 |
|
139 |
-
print(trans_text)
|
140 |
-
|
141 |
# テキストに書き出す
|
142 |
f.write(trans_text)
|
143 |
|
|
|
93 |
file_path = os.getcwd() + "/" + file_name
|
94 |
|
95 |
else:
|
96 |
+
|
97 |
+
# ファイル名のみ取得
|
98 |
+
file_name = os.path.basename(file)
|
99 |
+
|
100 |
+
# ファイルを移動
|
101 |
+
file_path = os.getcwd() + "/" + file_name
|
102 |
+
os.replace(file, file_path)
|
103 |
|
104 |
# 音声ファイルを分割
|
105 |
audio_list = audio_seg(file_path)
|
106 |
|
107 |
+
print(audio_list)
|
108 |
+
|
109 |
# whisperで文字に起こす
|
110 |
text_list = whisper_audio(client, audio_list, state["lang"])
|
111 |
|
|
|
139 |
# ファイル名設定
|
140 |
text_name = audio.replace(".mp3",".txt")
|
141 |
|
|
|
|
|
142 |
with open(text_name, mode="w") as f:
|
143 |
|
|
|
|
|
144 |
# テキストに書き出す
|
145 |
f.write(trans_text)
|
146 |
|