mirror of
https://github.com/voice-cloning-app/Voice-Cloning-App.git
synced 2025-12-24 07:29:37 +01:00
Add error logging
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<p class="error">
|
||||
<b>Type</b>: {{ error.type }}<br>
|
||||
<b>Text</b>: {{ error.text }}<br>
|
||||
<b>Full</b>: {{ error.full }}
|
||||
<b>Full</b>: {{ error.stacktrace }}
|
||||
</p>
|
||||
<a href="/" class="back">Go To Homepage</a>
|
||||
</div>
|
||||
|
||||
@@ -2,12 +2,16 @@ import logging
|
||||
from threading import Thread
|
||||
import os
|
||||
from datetime import datetime
|
||||
import requests
|
||||
|
||||
from main import socketio
|
||||
from dataset.clip_generator import clip_generator, extend_dataset
|
||||
from dataset.forced_alignment.align import align
|
||||
|
||||
|
||||
LOGGING_URL = "https://voice-cloning-app-logging.herokuapp.com/"
|
||||
|
||||
|
||||
class SocketIOHandler(logging.Handler):
|
||||
def emit(self, record):
|
||||
text = record.getMessage()
|
||||
@@ -40,15 +44,24 @@ def extend_existing_dataset(text_path, audio_path, forced_alignment_path, output
|
||||
extend_dataset(audio_path, forced_alignment_path, output_path, label_path, prefix, logging=logging)
|
||||
|
||||
|
||||
def send_error_log(error):
|
||||
try:
|
||||
response = requests.post(LOGGING_URL, data=error)
|
||||
if response.status_code != 201:
|
||||
print("error logging recieved invalid response")
|
||||
except:
|
||||
print("error logging failed")
|
||||
|
||||
|
||||
def background_task(func, **kwargs):
|
||||
exception = False
|
||||
try:
|
||||
socketio.sleep(5)
|
||||
func(logging=logger, **kwargs)
|
||||
except Exception as e:
|
||||
socketio.emit(
|
||||
"error", {"type": e.__class__.__name__, "text": str(e), "full": traceback.format_exc()}, namespace="/voice"
|
||||
)
|
||||
error = {"type": e.__class__.__name__, "text": str(e), "stacktrace": traceback.format_exc()}
|
||||
send_error_log(error)
|
||||
socketio.emit("error", error, namespace="/voice")
|
||||
exception = True
|
||||
print(e)
|
||||
|
||||
|
||||
@@ -10,7 +10,14 @@ import torch
|
||||
sys.path.append("synthesis/waveglow/")
|
||||
|
||||
from main import app, paths
|
||||
from application.utils import start_progress_thread, get_next_url, create_dataset, extend_existing_dataset, get_prefix
|
||||
from application.utils import (
|
||||
start_progress_thread,
|
||||
get_next_url,
|
||||
create_dataset,
|
||||
extend_existing_dataset,
|
||||
get_prefix,
|
||||
send_error_log,
|
||||
)
|
||||
from dataset.analysis import get_total_audio_duration
|
||||
from training.train import train
|
||||
from training.checkpoint import get_latest_checkpoint
|
||||
@@ -37,7 +44,8 @@ inflect_engine = inflect.engine()
|
||||
|
||||
@app.errorhandler(Exception)
|
||||
def handle_bad_request(e):
|
||||
error = {"type": e.__class__.__name__, "text": str(e), "full": traceback.format_exc()}
|
||||
error = {"type": e.__class__.__name__, "text": str(e), "stacktrace": traceback.format_exc()}
|
||||
send_error_log(error)
|
||||
return render_template("error.html", error=error)
|
||||
|
||||
|
||||
@@ -61,7 +69,7 @@ def get_page(endpoint):
|
||||
if endpoint == "synthesis" and not model:
|
||||
return redirect("/synthesis-setup")
|
||||
|
||||
return render_template(f"{endpoint}.html")
|
||||
return ender_template(f"{endpoint}.html")
|
||||
|
||||
|
||||
@app.route("/", methods=["POST"])
|
||||
|
||||
@@ -4,12 +4,14 @@ import argparse
|
||||
TARGET_SAMPLE_RATE = 22050
|
||||
TARGET_BITRATE = "32k"
|
||||
|
||||
|
||||
def compress_audio(input_path, output_path):
|
||||
command = (
|
||||
f"ffmpeg -i {input_path} -acodec libmp3lame -b:a {TARGET_BITRATE} -ac 1 -ar {TARGET_SAMPLE_RATE} {output_path}"
|
||||
)
|
||||
call(command.split(" "))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-i", "--input_path", type=str, help="input audio path")
|
||||
|
||||
Reference in New Issue
Block a user