add PlaySound node

This commit is contained in:
chflame163
2023-12-08 14:34:52 +08:00
parent ec50bb47a7
commit eb62b62122
3 changed files with 51 additions and 2 deletions
+46
View File
@@ -0,0 +1,46 @@
import sys
import os
import threading
from arcade import load_sound, play_sound
class Sound:
def play(self, file_name, volume):
sound = load_sound(file_name)
play_sound(sound, volume)
def Play(path, volume):
s = Sound()
s.play(path, volume)
class Play_Sound_Now():
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"path": ("STRING", {"default": 'comfyui.mp3'}),
"volume": ("FLOAT", {"default": 1, "min": 0.0, "max": 1.0, "step": 0.01}),
},
"optional": {
},
}
RETURN_TYPES = ()
FUNCTION = "do_playsound"
OUTPUT_NODE = True
CATEGORY = "MicorsoftSpeech_TTS"
def do_playsound(self, path, volume):
t = threading.Thread(target=Play(path, volume))
t.start()
return {"ui": {"text": ("",)}}
NODE_CLASS_MAPPINGS = {
"Play Sound": Play_Sound_Now
}