| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- from dash.dependencies import Input, Output, State, ALL
- from dash import html
- def register_tts_callbacks(app):
- @app.callback(
- Output("tts-training-status", "children"),
- Output("tts-training-status", "is_open"),
- Input("start-training-tts", "n_clicks"),
- State("start-training-tts", "disabled"),
- )
- def start_tts_training(n_clicks, disabled):
- if n_clicks:
- try:
- # Add your TTS training logic here
- return "TTS training started!", True
- except Exception as e:
- return f"Error during TTS training: {e}", True
- return "", False
- @app.callback(
- Output("tts-data-upload-status", "children"),
- Input("upload-tts-data", "contents"),
- State("upload-tts-data", "filename"),
- State("upload-tts-data", "last_modified"),
- )
- def upload_tts_data(contents, filename, last_modified):
- if contents:
- try:
- # Add your logic to handle the uploaded data
- return f"Uploaded {filename} successfully!", True
- except Exception as e:
- return f"Error during upload: {e}", True
- return "", False
- @app.callback(
- Output("tts-data-display", "children"),
- Input("refresh-tts-data", "n_clicks"),
- )
- def display_tts_data(n_clicks):
- if n_clicks:
- try:
- # Add your logic to fetch and display the TTS data
- tts_data = "Example TTS Data" # Replace with actual data fetching logic
- return html.Div([
- html.H5("TTS Data:"),
- html.Pre(tts_data)
- ])
- except Exception as e:
- return f"Error during data display: {e}"
- return html.Div("No TTS data to display")
- @app.callback(
- Output("tts-model-status", "children"),
- Input("refresh-tts-model-status", "n_clicks"),
- )
- def display_tts_model_status(n_clicks):
- if n_clicks:
- try:
- # Add your logic to fetch and display the TTS model status
- model_status = "TTS Model is up-to-date" # Replace with actual status checking logic
- return html.Div([
- html.H5("TTS Model Status:"),
- html.P(model_status)
- ])
- except Exception as e:
- return f"Error during model status display: {e}"
- return html.Div("No TTS model status to display")
|