Spaces:
Runtime error
Runtime error
Update transcription.py
Browse files- transcription.py +7 -9
transcription.py
CHANGED
|
@@ -1,23 +1,21 @@
|
|
| 1 |
import os
|
| 2 |
from faster_whisper import WhisperModel
|
| 3 |
from pydub import AudioSegment
|
|
|
|
| 4 |
# Matplotlibのキャッシュディレクトリを変更
|
| 5 |
os.environ["MPLCONFIGDIR"] = "/tmp/matplotlib"
|
| 6 |
|
| 7 |
# Hugging Faceのキャッシュディレクトリを変更
|
| 8 |
os.environ["HF_HOME"] = "/tmp/huggingface"
|
|
|
|
| 9 |
|
| 10 |
class TranscriptionMaker():
|
| 11 |
-
|
| 12 |
-
def __init__(self,output_dir="/tmp/data/transcriptions"):
|
| 13 |
-
self.model = WhisperModel("base", device="cpu")
|
| 14 |
self.output_dir = output_dir
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
os.makedirs(self.output_dir)
|
| 18 |
-
except OSError as e:
|
| 19 |
-
print(f"Error creating directory {self.output_dir}: {e}")
|
| 20 |
-
raise
|
| 21 |
|
| 22 |
#音声ファイルのディレクトリを受け取り、書き起こしファイルを作成する
|
| 23 |
def create_transcription(self,segments_directory):
|
|
|
|
| 1 |
import os
|
| 2 |
from faster_whisper import WhisperModel
|
| 3 |
from pydub import AudioSegment
|
| 4 |
+
|
| 5 |
# Matplotlibのキャッシュディレクトリを変更
|
| 6 |
os.environ["MPLCONFIGDIR"] = "/tmp/matplotlib"
|
| 7 |
|
| 8 |
# Hugging Faceのキャッシュディレクトリを変更
|
| 9 |
os.environ["HF_HOME"] = "/tmp/huggingface"
|
| 10 |
+
os.environ["HUGGINGFACE_HUB_CACHE"] = "/tmp/huggingface"
|
| 11 |
|
| 12 |
class TranscriptionMaker():
|
| 13 |
+
# 書き起こしファイルを吐き出すディレクトリを指定
|
| 14 |
+
def __init__(self, output_dir="/tmp/data/transcriptions"):
|
| 15 |
+
self.model = WhisperModel("base", device="cpu", download_root="/tmp/huggingface")
|
| 16 |
self.output_dir = output_dir
|
| 17 |
+
os.makedirs(self.output_dir, exist_ok=True)
|
| 18 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
#音声ファイルのディレクトリを受け取り、書き起こしファイルを作成する
|
| 21 |
def create_transcription(self,segments_directory):
|