programindz commited on
Commit
f1801f1
·
1 Parent(s): ea0540c

removed translation

Browse files
Files changed (3) hide show
  1. Dockerfile +6 -6
  2. app/index.html +37 -37
  3. app/main.py +5 -7
Dockerfile CHANGED
@@ -6,15 +6,15 @@ RUN apt-get update && apt-get install -y \
6
  ffmpeg libsndfile1 git curl build-essential && \
7
  rm -rf /var/lib/apt/lists/*
8
 
9
- RUN git clone https://github.com/VarunGumma/IndicTransToolkit \
10
- && cd IndicTransToolkit \
11
- && pip install --editable . --use-pep517
12
 
13
  WORKDIR /code
14
 
15
- # Set HF cache to a writable directory
16
- ENV HF_HOME=/code/app/hf_cache
17
- ENV TRANSFORMERS_CACHE=/code/app/hf_cache
18
 
19
  # Copy code
20
  COPY ./app /code/app
 
6
  ffmpeg libsndfile1 git curl build-essential && \
7
  rm -rf /var/lib/apt/lists/*
8
 
9
+ # RUN git clone https://github.com/VarunGumma/IndicTransToolkit \
10
+ # && cd IndicTransToolkit \
11
+ # && pip install --editable . --use-pep517
12
 
13
  WORKDIR /code
14
 
15
+ # # Set HF cache to a writable directory
16
+ # ENV HF_HOME=/code/app/hf_cache
17
+ # ENV TRANSFORMERS_CACHE=/code/app/hf_cache
18
 
19
  # Copy code
20
  COPY ./app /code/app
app/index.html CHANGED
@@ -130,19 +130,19 @@
130
  <div id="transcript" class="transcript-container">…</div>
131
  </section>
132
 
133
- <section class="section--translate">
134
  <!-- <h2>Translation</h2> -->
135
- <button id="translateBtn" onclick="sendForTranslation()">🌐 Translate to English</button>
136
- <div id="translatedText" class="transcript-container" style="margin-top: 1rem;">…</div>
137
- </section>
138
 
139
  </section>
140
 
141
  <script>
142
  let orig_sample_rate;
143
  let ws;
144
- let lastTranslatedText = "";
145
- let lastTranslation = "";
146
 
147
  const vol = document.getElementById("vol");
148
  const transcript = document.getElementById("transcript");
@@ -254,37 +254,37 @@
254
 
255
  // This part is for translation
256
 
257
- async function sendForTranslation() {
258
- const fullText = finalUtterances.join(" ").trim();
259
-
260
- if (!fullText) {
261
- // alert("No transcript to translate.");
262
- console.log('[TRANSLATION] Nothing to translate')
263
- return;
264
- }
265
-
266
- if (fullText === lastTranslatedText) {
267
- console.log("Using cached translation");
268
- document.getElementById("translatedText").textContent = lastTranslation;
269
- return;
270
- }
271
-
272
- const response = await fetch("/translate", {
273
- method: "POST",
274
- headers: {
275
- "Content-Type": "application/json"
276
- },
277
- body: JSON.stringify({ text: fullText })
278
- });
279
-
280
- const data = await response.json();
281
-
282
- lastTranslatedText = fullText;
283
- lastTranslation = data.translation;
284
-
285
- // Display result
286
- document.getElementById("translatedText").textContent = data.translation;
287
- }
288
 
289
 
290
  </script>
 
130
  <div id="transcript" class="transcript-container">…</div>
131
  </section>
132
 
133
+ <!-- <section class="section--translate"> -->
134
  <!-- <h2>Translation</h2> -->
135
+ <!-- <button id="translateBtn" onclick="sendForTranslation()">🌐 Translate to English</button> -->
136
+ <!-- <div id="translatedText" class="transcript-container" style="margin-top: 1rem;">…</div> -->
137
+ <!-- </section> -->
138
 
139
  </section>
140
 
141
  <script>
142
  let orig_sample_rate;
143
  let ws;
144
+ // let lastTranslatedText = "";
145
+ // let lastTranslation = "";
146
 
147
  const vol = document.getElementById("vol");
148
  const transcript = document.getElementById("transcript");
 
254
 
255
  // This part is for translation
256
 
257
+ // async function sendForTranslation() {
258
+ // const fullText = finalUtterances.join(" ").trim();
259
+
260
+ // if (!fullText) {
261
+ // // alert("No transcript to translate.");
262
+ // console.log('[TRANSLATION] Nothing to translate')
263
+ // return;
264
+ // }
265
+
266
+ // if (fullText === lastTranslatedText) {
267
+ // console.log("Using cached translation");
268
+ // document.getElementById("translatedText").textContent = lastTranslation;
269
+ // return;
270
+ // }
271
+
272
+ // const response = await fetch("/translate", {
273
+ // method: "POST",
274
+ // headers: {
275
+ // "Content-Type": "application/json"
276
+ // },
277
+ // body: JSON.stringify({ text: fullText })
278
+ // });
279
+
280
+ // const data = await response.json();
281
+
282
+ // lastTranslatedText = fullText;
283
+ // lastTranslation = data.translation;
284
+
285
+ // // Display result
286
+ // document.getElementById("translatedText").textContent = data.translation;
287
+ // }
288
 
289
 
290
  </script>
app/main.py CHANGED
@@ -1,11 +1,9 @@
1
  from fastapi import FastAPI, WebSocket
2
  from fastapi.responses import HTMLResponse
3
  from app.asr import create_recognizer, stream_audio
4
- from app.translation import tranlate_ks
5
  import json
6
  from pydantic import BaseModel
7
- import os
8
-
9
 
10
  app = FastAPI()
11
 
@@ -112,7 +110,7 @@ class TranslationRequest(BaseModel):
112
  text: str
113
 
114
 
115
- @app.post("/translate")
116
- async def translate_text(req: TranslationRequest):
117
- print('[Translation] Request recieved . . . ')
118
- return tranlate_ks(req.text)
 
1
  from fastapi import FastAPI, WebSocket
2
  from fastapi.responses import HTMLResponse
3
  from app.asr import create_recognizer, stream_audio
4
+ # from app.translation import tranlate_ks
5
  import json
6
  from pydantic import BaseModel
 
 
7
 
8
  app = FastAPI()
9
 
 
110
  text: str
111
 
112
 
113
+ # @app.post("/translate")
114
+ # async def translate_text(req: TranslationRequest):
115
+ # print('[Translation] Request recieved . . . ')
116
+ # return tranlate_ks(req.text)