Oviya
commited on
Commit
·
5a912a4
1
Parent(s):
0b92c10
fix audio issue
Browse files
src/app/pronunciation/pronunciation.component.ts
CHANGED
|
@@ -188,7 +188,8 @@ export class PronunciationComponent implements OnDestroy, OnInit {
|
|
| 188 |
const staticPath = this.getStaticTeacherAudioPath(this.word);
|
| 189 |
this.isTeacherLoading = true;
|
| 190 |
try {
|
| 191 |
-
|
|
|
|
| 192 |
if (resp.ok) {
|
| 193 |
this.teacherAudioCache.set(this.word, staticPath);
|
| 194 |
this.playAudioWithWaveform(staticPath, 'teacher');
|
|
@@ -201,6 +202,7 @@ export class PronunciationComponent implements OnDestroy, OnInit {
|
|
| 201 |
this.isTeacherLoading = false;
|
| 202 |
}
|
| 203 |
|
|
|
|
| 204 |
const cached = this.teacherAudioCache.get(this.word);
|
| 205 |
if (cached) {
|
| 206 |
this.isTeacherLoading = true;
|
|
@@ -213,7 +215,7 @@ export class PronunciationComponent implements OnDestroy, OnInit {
|
|
| 213 |
|
| 214 |
// Try streaming audio bytes from the backend (no server-side file). Fallback to existing blob/url flows.
|
| 215 |
this.api.generateTeacherAudioStream(this.word, this.selectedFile).subscribe({
|
| 216 |
-
next: (blob) => {
|
| 217 |
try {
|
| 218 |
const objUrl = URL.createObjectURL(blob);
|
| 219 |
const prev = this.teacherAudioCache.get(this.word);
|
|
|
|
| 188 |
const staticPath = this.getStaticTeacherAudioPath(this.word);
|
| 189 |
this.isTeacherLoading = true;
|
| 190 |
try {
|
| 191 |
+
// Use GET instead of HEAD – HF serves GET correctly
|
| 192 |
+
const resp = await fetch(staticPath, { method: 'GET' });
|
| 193 |
if (resp.ok) {
|
| 194 |
this.teacherAudioCache.set(this.word, staticPath);
|
| 195 |
this.playAudioWithWaveform(staticPath, 'teacher');
|
|
|
|
| 202 |
this.isTeacherLoading = false;
|
| 203 |
}
|
| 204 |
|
| 205 |
+
|
| 206 |
const cached = this.teacherAudioCache.get(this.word);
|
| 207 |
if (cached) {
|
| 208 |
this.isTeacherLoading = true;
|
|
|
|
| 215 |
|
| 216 |
// Try streaming audio bytes from the backend (no server-side file). Fallback to existing blob/url flows.
|
| 217 |
this.api.generateTeacherAudioStream(this.word, this.selectedFile).subscribe({
|
| 218 |
+
next: (blob:any) => {
|
| 219 |
try {
|
| 220 |
const objUrl = URL.createObjectURL(blob);
|
| 221 |
const prev = this.teacherAudioCache.get(this.word);
|