Aditi Tewari commited on
Commit
b77c785
·
1 Parent(s): b7fe9cf

Update backend and frontend

Browse files
Files changed (2) hide show
  1. soundscripter.html +2 -2
  2. soundscripter_flaskAPI.py +7 -5
soundscripter.html CHANGED
@@ -16,7 +16,7 @@
16
 
17
  <nav class="navbar" style="background-color:whitesmoke; height:98px; border-radius:30px" >
18
  <div>
19
- <img src="wave.png" alt="SoundScripter" width="60" height="70" style="margin-top:-5px">
20
  <span class="navbar-brand" style="font-size:35px;"><b>SoundScripter</b></span>
21
  </div>
22
  <h5>Automatic Speech Recognition</h5>
@@ -117,7 +117,7 @@
117
  })
118
  .then((response) => response.json())
119
  .then((data) => {
120
- if (data.Text) {
121
  outputText.value = data.text;
122
  } else {
123
  outputText.value = "No text recognized.";
 
16
 
17
  <nav class="navbar" style="background-color:whitesmoke; height:98px; border-radius:30px" >
18
  <div>
19
+ <img src="https://huggingface.co/spaces/adititewari/SoundScripter/blob/main/wave.png" alt="SoundScripter" width="60" height="70" style="margin-top:-5px">
20
  <span class="navbar-brand" style="font-size:35px;"><b>SoundScripter</b></span>
21
  </div>
22
  <h5>Automatic Speech Recognition</h5>
 
117
  })
118
  .then((response) => response.json())
119
  .then((data) => {
120
+ if (data.text) {
121
  outputText.value = data.text;
122
  } else {
123
  outputText.value = "No text recognized.";
soundscripter_flaskAPI.py CHANGED
@@ -30,7 +30,8 @@ async def read_root():
30
  # Provide the path to the HTML file containing the front-end code
31
  with open("soundscripter.html", "r") as file:
32
  html_content = file.read()
33
- return HTMLResponse(content=html_content)
 
34
 
35
 
36
  def convert_audio_format(input_data, input_format, output_format='wav'):
@@ -52,11 +53,11 @@ def recognize_speech(audio_data, language="hi-IN"):
52
  return f"API request failed: {e}"
53
 
54
  @app.post("/asr")
55
- async def transcribe_audio(file: UploadFile = File(...)):
56
- contents = await file.read()
57
 
58
  # Determine the input audio format (assumes the format is part of the file name)
59
- input_format = file.filename.split('.')[-1].lower()
60
 
61
  # Convert audio to WAV format
62
  wav_data = convert_audio_format(contents, input_format)
@@ -68,7 +69,8 @@ async def transcribe_audio(file: UploadFile = File(...)):
68
 
69
  # Transcribe the audio
70
  result = recognize_speech(wav_data)
71
-
 
72
  # return {"Text": result}
73
  return JSONResponse(content={"text": result})
74
 
 
30
  # Provide the path to the HTML file containing the front-end code
31
  with open("soundscripter.html", "r") as file:
32
  html_content = file.read()
33
+ # return HTMLResponse(content=html_content)
34
+ return html_content
35
 
36
 
37
  def convert_audio_format(input_data, input_format, output_format='wav'):
 
53
  return f"API request failed: {e}"
54
 
55
  @app.post("/asr")
56
+ async def transcribe_audio(audio: UploadFile = File(...)):
57
+ contents = await audio.read()
58
 
59
  # Determine the input audio format (assumes the format is part of the file name)
60
+ input_format = audio.filename.split('.')[-1].lower()
61
 
62
  # Convert audio to WAV format
63
  wav_data = convert_audio_format(contents, input_format)
 
69
 
70
  # Transcribe the audio
71
  result = recognize_speech(wav_data)
72
+ print(result)
73
+ # print(JSONResponse(content={"text": result}))
74
  # return {"Text": result}
75
  return JSONResponse(content={"text": result})
76