Aswinthmani commited on
Commit
eb67307
·
verified ·
1 Parent(s): 00bc6ba

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +4 -4
main.py CHANGED
@@ -9,7 +9,7 @@ import soundfile as sf
9
 
10
  app = FastAPI()
11
 
12
- # Allow frontend to call backend
13
  app.add_middleware(
14
  CORSMiddleware,
15
  allow_origins=["*"],
@@ -18,7 +18,7 @@ app.add_middleware(
18
  allow_headers=["*"],
19
  )
20
 
21
- # Supported languages
22
  translation_models = {
23
  "fr": "Helsinki-NLP/opus-mt-en-fr",
24
  "es": "Helsinki-NLP/opus-mt-en-es",
@@ -31,8 +31,8 @@ translation_models = {
31
  "ta": "Helsinki-NLP/opus-mt-en-ta"
32
  }
33
 
34
- # Load models once
35
- generator = pipeline("text-generation", model="distilgpt2", framework="tf", from_tf=True)
36
  whisper_model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-base")
37
  whisper_processor = WhisperProcessor.from_pretrained("openai/whisper-base")
38
 
 
9
 
10
  app = FastAPI()
11
 
12
+ # CORS Configuration
13
  app.add_middleware(
14
  CORSMiddleware,
15
  allow_origins=["*"],
 
18
  allow_headers=["*"],
19
  )
20
 
21
+ # Translation Models
22
  translation_models = {
23
  "fr": "Helsinki-NLP/opus-mt-en-fr",
24
  "es": "Helsinki-NLP/opus-mt-en-es",
 
31
  "ta": "Helsinki-NLP/opus-mt-en-ta"
32
  }
33
 
34
+ # Initialize Models CORRECTLY
35
+ generator = pipeline("text-generation", model="distilgpt2") # Fixed: Removed TF args, fixed model name
36
  whisper_model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-base")
37
  whisper_processor = WhisperProcessor.from_pretrained("openai/whisper-base")
38