Add --transcribe option to CLI for generating LilyPond transcriptions

This commit is contained in:
Michael Winter 2026-03-23 19:46:00 +01:00
parent 9dbde6a63d
commit 306de8b5c2

View file

@ -410,6 +410,13 @@ def main():
default=None, default=None,
help="Enable OSC playback (optionally specify chord file, default: output/output_chords.json)", help="Enable OSC playback (optionally specify chord file, default: output/output_chords.json)",
) )
parser.add_argument(
"--transcribe",
nargs="*",
metavar=("INPUT", "OUTPUT"),
default=None,
help="Generate LilyPond transcription (optionally: input_file output_name)",
)
parser.add_argument( parser.add_argument(
"--osc-ip", "--osc-ip",
type=str, type=str,
@ -430,6 +437,33 @@ def main():
) )
args = parser.parse_args() args = parser.parse_args()
# Handle transcription mode (separate from generation)
if args.transcribe is not None:
import json
from .transcriber import transcribe
input_file = (
args.transcribe[0]
if len(args.transcribe) > 0
else "output/output_chords.json"
)
output_name = (
args.transcribe[1]
if len(args.transcribe) > 1
else "compact_sets_transcription"
)
with open(input_file) as f:
chords = json.load(f)
print(f"Transcribing {len(chords)} chords from {input_file}")
transcribe(
chords,
output_name,
fundamental=args.fundamental,
)
return # Exit after transcribing
# Handle OSC playback mode (separate from generation) # Handle OSC playback mode (separate from generation)
if args.osc_play: if args.osc_play:
from .osc_sender import OSCSender from .osc_sender import OSCSender