diff --git a/nodes.py b/nodes.py index 4b5aa81..852bf0d 100644 --- a/nodes.py +++ b/nodes.py @@ -95,28 +95,54 @@ def _encode_audio_b64(audio) -> str: return _tensor_to_wav_b64(waveform, audio["sample_rate"]) +def _parse_wav_bytes(audio_bytes: bytes): + """Parse WAV bytes manually to support PCM (fmt=1) and float32 (fmt=3).""" + if audio_bytes[:4] != b"RIFF" or audio_bytes[8:12] != b"WAVE": + raise RuntimeError("Not a valid WAV file") + pos = 12 + fmt_tag = n_channels = sample_rate = sampwidth = 0 + data_offset = data_size = 0 + while pos < len(audio_bytes) - 8: + chunk_id = audio_bytes[pos:pos+4] + chunk_size = struct.unpack_from(" 80 else ''}\n" - f"bpm: {gp.get('bpm', 0)} key: {gp.get('key_scale', '')} " - f"duration: {gp.get('duration', -1.0)} time_sig: {gp.get('time_signature', '')}\n" - f"vocal_language: {gp.get('vocal_language', '')} " - f"instrumental: {gp.get('instrumental', False)}" - ) - if actual_task == "cover": - param_summary += ( - f"\ncover_strength: {gp.get('cover_strength', 0.0)} " - f"remix_strength: {gp.get('remix_strength', 1.0)}" - ) - if gp.get("audio_codes"): - param_summary += f"\naudio_codes: {len(gp['audio_codes'])} chars" - if actual_task == "repaint": - param_summary += ( - f"\nrepaint_start: {gp.get('repaint_start', 0.0)} " - f"repaint_end: {gp.get('repaint_end', 0.0)}" - ) - info_parts.append(f"=== Gen Params ===\n{param_summary}") - - if text_content: - info_parts.append(f"\n=== Server Response ===\n{text_content}") out_codes = "" choices = result.get("choices", []) if choices: msg = choices[0].get("message", {}) out_codes = msg.get("audio_codes", "") or "" - if out_codes: - info_parts.append(f"\n=== Audio Codes ({len(out_codes)} chars) ===") - info = "\n".join(info_parts) - - return (audio, info, out_codes) + return (audio, text_content, out_codes) # ============================================================================= @@ -714,7 +708,7 @@ class AceStepText2MusicServer: class AceStepShowText: """Display any STRING input as text.""" - CATEGORY = "ACE-Step" + CATEGORY = "api node/audio/ACE-Step" FUNCTION = "show" RETURN_TYPES = ("STRING",) RETURN_NAMES = ("text",)