aether-raider commited on
Commit
f6d739b
·
1 Parent(s): 2cd38da

testing sample audios fix

Browse files
.gitattributes CHANGED
@@ -32,4 +32,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.xz filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -textss
 
 
 
32
  *.xz filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.wav filter=lfs diff=lfs merge=lfs -text
37
+ audios/*.wav filter=lfs diff=lfs merge=lfs -text
backend/__pycache__/data_manager.cpython-311.pyc CHANGED
Binary files a/backend/__pycache__/data_manager.cpython-311.pyc and b/backend/__pycache__/data_manager.cpython-311.pyc differ
 
backend/__pycache__/session_manager.cpython-311.pyc CHANGED
Binary files a/backend/__pycache__/session_manager.cpython-311.pyc and b/backend/__pycache__/session_manager.cpython-311.pyc differ
 
backend/session_manager.py CHANGED
@@ -111,40 +111,60 @@ class SessionManager:
111
  # Sample clips (for the reference/sample section)
112
  # Use hardcoded reference audio files instead of dataset clips
113
  import os
 
 
114
  mos_dir = os.path.dirname(os.path.dirname(__file__))
115
  audios_dir = os.path.join(mos_dir, "audios")
116
 
117
  male_path = os.path.join(audios_dir, "male.wav")
118
  female_path = os.path.join(audios_dir, "female.wav")
119
 
120
- print(f"[INFO] Sample audio paths:")
121
- print(f" Male: {male_path} (exists: {os.path.exists(male_path)})")
122
- print(f" Female: {female_path} (exists: {os.path.exists(female_path)})")
123
- if os.path.exists(male_path):
124
- print(f" Male file size: {os.path.getsize(male_path)} bytes")
125
- if os.path.exists(female_path):
126
- print(f" Female file size: {os.path.getsize(female_path)} bytes")
 
 
 
 
 
 
 
 
 
 
 
 
 
127
 
128
- sample_clips = [
129
- Clip(
130
- id="reference_male",
131
- model="reference",
132
- speaker="male",
133
- exercise="reference",
134
- exercise_id="ref_male",
135
- transcript="TENGAH Approach to CAMEL, CAMEL identified on squawk, QNH 29.80, Delta 4 hot, report abeam Tuas.",
136
- audio_url=male_path,
137
- ),
138
- Clip(
139
- id="reference_female",
140
- model="reference",
141
- speaker="female",
142
- exercise="reference",
143
- exercise_id="ref_female",
144
- transcript="JOHOR climbing to flight level 300, contact Approach on 123.45.",
145
- audio_url=female_path,
146
- ),
147
- ]
 
 
 
 
 
148
 
149
  session_data: Dict[str, Any] = {
150
  "session_id": session_id,
 
111
  # Sample clips (for the reference/sample section)
112
  # Use hardcoded reference audio files instead of dataset clips
113
  import os
114
+ import base64
115
+
116
  mos_dir = os.path.dirname(os.path.dirname(__file__))
117
  audios_dir = os.path.join(mos_dir, "audios")
118
 
119
  male_path = os.path.join(audios_dir, "male.wav")
120
  female_path = os.path.join(audios_dir, "female.wav")
121
 
122
+ # Helper function to load audio as base64 data URL (for LFS compatibility)
123
+ def load_audio_as_data_url(path):
124
+ if os.path.exists(path):
125
+ try:
126
+ with open(path, "rb") as f:
127
+ audio_bytes = f.read()
128
+ # Check if it's an LFS pointer (small text file)
129
+ if len(audio_bytes) < 200 and b"version https://git-lfs.github.com" in audio_bytes:
130
+ print(f"[WARN] {path} is an LFS pointer, cannot load")
131
+ return None
132
+ b64 = base64.b64encode(audio_bytes).decode("ascii")
133
+ return f"data:audio/wav;base64,{b64}"
134
+ except Exception as e:
135
+ print(f"[ERROR] Failed to load {path}: {e}")
136
+ return None
137
+ print(f"[ERROR] File not found: {path}")
138
+ return None
139
+
140
+ male_audio = load_audio_as_data_url(male_path)
141
+ female_audio = load_audio_as_data_url(female_path)
142
 
143
+ sample_clips = []
144
+ if male_audio:
145
+ sample_clips.append(
146
+ Clip(
147
+ id="reference_male",
148
+ model="reference",
149
+ speaker="male",
150
+ exercise="reference",
151
+ exercise_id="ref_male",
152
+ transcript="TENGAH Approach to CAMEL, CAMEL identified on squawk, QNH 29.80, Delta 4 hot, report abeam Tuas.",
153
+ audio_url=male_audio,
154
+ )
155
+ )
156
+ if female_audio:
157
+ sample_clips.append(
158
+ Clip(
159
+ id="reference_female",
160
+ model="reference",
161
+ speaker="female",
162
+ exercise="reference",
163
+ exercise_id="ref_female",
164
+ transcript="JOHOR climbing to flight level 300, contact Approach on 123.45.",
165
+ audio_url=female_audio,
166
+ )
167
+ )
168
 
169
  session_data: Dict[str, Any] = {
170
  "session_id": session_id,