agent404 commited on
Commit
2e8ae70
·
1 Parent(s): 01b6cc4

update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -23,7 +23,7 @@ K:G
23
  """
24
 
25
  def parse_abc_notation(text='', conversation_id='debug'):
26
- os.makedirs(f"tmp/{conversation_id}", exist_ok=True)
27
  ts = time.time()
28
  abc_pattern = r'(X:\d+\n(?:[^\n]*\n)+)'
29
  abc_notation = re.findall(abc_pattern, text+'\n')
@@ -31,14 +31,14 @@ def parse_abc_notation(text='', conversation_id='debug'):
31
  if abc_notation:
32
  # Convert ABC to midi
33
  s = Score.from_abc(abc_notation[0])
34
- wav_file = f'tmp/{conversation_id}/{ts}.mp3'
35
  audio = Synthesizer().render(s, stereo=True)
36
  torchaudio.save(wav_file, torch.FloatTensor(audio), 44100)
37
 
38
  # Convert abc notation to SVG
39
- tmp_midi = f'tmp/{conversation_id}/{ts}.mid'
40
  s.dump_midi(tmp_midi)
41
- svg_file = f'tmp/{conversation_id}/{ts}.svg'
42
  subprocess.run(["./MuseScore-4.1.1.232071203-x86_64.AppImage", "-f", "-o", svg_file, tmp_midi])
43
  return svg_file, wav_file
44
  else:
 
23
  """
24
 
25
  def parse_abc_notation(text='', conversation_id='debug'):
26
+ # os.makedirs(f"tmp/", exist_ok=True)
27
  ts = time.time()
28
  abc_pattern = r'(X:\d+\n(?:[^\n]*\n)+)'
29
  abc_notation = re.findall(abc_pattern, text+'\n')
 
31
  if abc_notation:
32
  # Convert ABC to midi
33
  s = Score.from_abc(abc_notation[0])
34
+ wav_file = f'{ts}.mp3'
35
  audio = Synthesizer().render(s, stereo=True)
36
  torchaudio.save(wav_file, torch.FloatTensor(audio), 44100)
37
 
38
  # Convert abc notation to SVG
39
+ tmp_midi = f'{ts}.mid'
40
  s.dump_midi(tmp_midi)
41
+ svg_file = f'{ts}.svg'
42
  subprocess.run(["./MuseScore-4.1.1.232071203-x86_64.AppImage", "-f", "-o", svg_file, tmp_midi])
43
  return svg_file, wav_file
44
  else: