Ali Sartaz Khan commited on
Commit
1c933d8
·
1 Parent(s): cc08a1c
recording_tracker.json CHANGED
@@ -46,5 +46,35 @@
46
  "audio_hash": "7908731e",
47
  "filename": "test/prompt2_7908731e_f7c7fa54.wav",
48
  "timestamp": "49f8bab8-7e44-4cb9-9155-3be03a3afddd"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
  ]
 
46
  "audio_hash": "7908731e",
47
  "filename": "test/prompt2_7908731e_f7c7fa54.wav",
48
  "timestamp": "49f8bab8-7e44-4cb9-9155-3be03a3afddd"
49
+ },
50
+ {
51
+ "prompt": "",
52
+ "audio_hash": "fc7c499b",
53
+ "filename": "pilot_tempo_control6/_fc7c499b_0cf743d9.wav",
54
+ "timestamp": "8ac3802e-251b-43c6-9f34-258b0bb92648"
55
+ },
56
+ {
57
+ "prompt": "",
58
+ "audio_hash": "99c0ba0c",
59
+ "filename": "pilot_tempo_control6/_99c0ba0c_c1f82184.wav",
60
+ "timestamp": "c81ebd9d-7277-4fda-a413-61855483283e"
61
+ },
62
+ {
63
+ "prompt": "",
64
+ "audio_hash": "72860f45",
65
+ "filename": "pilot_tempo_control6/_72860f45_9a25752c.wav",
66
+ "timestamp": "d5bb27f3-46d7-490b-a27a-f5fff976e9d6"
67
+ },
68
+ {
69
+ "prompt": "",
70
+ "audio_hash": "866cedd5",
71
+ "filename": "pilot_tempo_control6/_866cedd5_08f3a22d.wav",
72
+ "timestamp": "6b38a09a-12d2-4e92-b475-0dd149a2b5d3"
73
+ },
74
+ {
75
+ "prompt": "",
76
+ "audio_hash": "cc1f9234",
77
+ "filename": "pilot_tempo_control6/_cc1f9234_2763ff75.wav",
78
+ "timestamp": "eda94b9d-30e5-44f7-89bd-4b9349b38a81"
79
  }
80
  ]
talk_arena/__pycache__/audio_collection.cpython-312.pyc CHANGED
Binary files a/talk_arena/__pycache__/audio_collection.cpython-312.pyc and b/talk_arena/__pycache__/audio_collection.cpython-312.pyc differ
 
talk_arena/audio_collection.py CHANGED
@@ -106,51 +106,26 @@ def upload_to_hf(local_path, repo_path):
106
  def on_submit(audio_input, recording_count):
107
  """Handle the submission of a recorded audio prompt"""
108
  if audio_input is None:
109
- return (
110
- gr.Markdown(f"# Recording {recording_count + 1}/{MAX_RECORDINGS}"),
111
- gr.Markdown(USER_INSTRUCTIONS),
112
- gr.Markdown(f"### \"{RECORDING_PROMPT}\""),
113
- gr.Audio(value=None, label="Record your response"),
114
- gr.Button("Submit Recording", interactive=False),
115
- gr.Button("Next Recording", visible=False),
116
- recording_count
117
- )
118
-
119
  # Process the audio
120
  sr, y = audio_input
121
-
122
- # Generate a hash for this audio
123
  audio_hash = xxhash.xxh32(bytes(y)).hexdigest()
124
-
125
- # Normalize audio
126
  y = y.astype(np.float32)
127
  y /= np.max(np.abs(y)) if np.max(np.abs(y)) > 0 else 1.0
128
 
129
- # Create unique filename
130
  unique_id = str(uuid.uuid4())[:8]
131
  clean_prompt = RECORDING_PROMPT.replace(" ", "_").replace(".", "").replace(",", "")[:20]
132
  local_filename = f"outputs/{clean_prompt}_{audio_hash}_{unique_id}.wav"
133
-
134
- # Save the original (non-resampled) audio
135
  sf.write(local_filename, y, sr, format="wav")
136
 
137
- # Upload to HF dataset
138
  hf_path = f"{CATEGORY}/{clean_prompt}_{audio_hash}_{unique_id}.wav"
139
  upload_to_hf(local_filename, hf_path)
140
 
141
- # Add to tracker
142
  tracker.add_recording(audio_hash, hf_path)
143
-
144
- # Show success message
145
- return (
146
- gr.Markdown(f"# Recording {recording_count + 1}/{MAX_RECORDINGS}"),
147
- gr.Markdown(USER_INSTRUCTIONS),
148
- gr.Markdown(f"### Recording successfully uploaded!"),
149
- gr.Audio(value=None, label="Record your response"),
150
- gr.Button("Submit Recording", interactive=False),
151
- gr.Button("Next Recording", visible=True),
152
- recording_count
153
- )
154
 
155
  def next_prompt(recording_count):
156
  """Move to the next prompt"""
 
106
  def on_submit(audio_input, recording_count):
107
  """Handle the submission of a recorded audio prompt"""
108
  if audio_input is None:
109
+ return next_prompt(recording_count)
110
+
 
 
 
 
 
 
 
 
111
  # Process the audio
112
  sr, y = audio_input
 
 
113
  audio_hash = xxhash.xxh32(bytes(y)).hexdigest()
 
 
114
  y = y.astype(np.float32)
115
  y /= np.max(np.abs(y)) if np.max(np.abs(y)) > 0 else 1.0
116
 
 
117
  unique_id = str(uuid.uuid4())[:8]
118
  clean_prompt = RECORDING_PROMPT.replace(" ", "_").replace(".", "").replace(",", "")[:20]
119
  local_filename = f"outputs/{clean_prompt}_{audio_hash}_{unique_id}.wav"
 
 
120
  sf.write(local_filename, y, sr, format="wav")
121
 
 
122
  hf_path = f"{CATEGORY}/{clean_prompt}_{audio_hash}_{unique_id}.wav"
123
  upload_to_hf(local_filename, hf_path)
124
 
 
125
  tracker.add_recording(audio_hash, hf_path)
126
+
127
+ # After successful upload, immediately move to the next prompt
128
+ return next_prompt(recording_count)
 
 
 
 
 
 
 
 
129
 
130
  def next_prompt(recording_count):
131
  """Move to the next prompt"""