From ba7a8401d8e9ed8a4d62306031eb2e8b0275a317 Mon Sep 17 00:00:00 2001 From: plague_spreader Date: Thu, 21 Mar 2024 23:03:32 +0100 Subject: [PATCH] Using pathlib as it is more convenient... ... also added an exception for unexpected OS platforms --- rvcgui.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rvcgui.py b/rvcgui.py index 8b5d12209..5f2910bac 100644 --- a/rvcgui.py +++ b/rvcgui.py @@ -4,6 +4,7 @@ import soundfile as sf import tkinter as tk import customtkinter as ctk +import pathlib import os import sys @@ -63,15 +64,15 @@ def extract_model_from_zip(zip_path, output_dir): def play_audio(file_path): + audio_file = pathlib.Path(file_path).absolute() if sys.platform == 'win32': - audio_file = os.path.abspath(file_path) subprocess.call(['start', '', audio_file], shell=True) elif sys.platform == 'darwin': - audio_file = 'path/to/audio/file.wav' subprocess.call(['open', audio_file]) elif sys.platform == 'linux': - audio_file = 'path/to/audio/file.wav' subprocess.call(['xdg-open', audio_file]) + else: + raise ValueError(f'Unexpected platform {sys.platform}') def get_full_path(path): return os.path.abspath(path)