поделал сайт, сделал orm-модели, requirements.txt
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import os
|
||||
from typing import List, Dict, Any
|
||||
|
||||
|
||||
def get_log(log_id: int) -> List[Dict[str, Any]]:
|
||||
log_dir = os.path.join("static/logs", str(log_id))
|
||||
return_dir = []
|
||||
for dir_path, _, filenames in os.walk(log_dir):
|
||||
if dir_path != log_dir:
|
||||
audio_file = os.path.join(dir_path, "audio.ogg")
|
||||
if not os.path.exists(audio_file):
|
||||
audio_file = os.path.join(dir_path, "audio.wav")
|
||||
text_file = os.path.join(dir_path, "yandex-text.txt")
|
||||
if not os.path.exists(text_file):
|
||||
text_file = os.path.join(dir_path, "google-text.txt")
|
||||
try:
|
||||
return_dir.append({"id": log_id, "audio_file": f"/{audio_file}",
|
||||
"text": open(text_file).read().split("\n")})
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
return return_dir
|
||||
Reference in New Issue
Block a user