kowalsky commited on
Commit
5573875
·
1 Parent(s): b5d69b2

deleted the comments

Browse files
Files changed (1) hide show
  1. main.py +1 -5
main.py CHANGED
@@ -141,25 +141,21 @@ async def stop_detection():
141
  @app.post("/upload_audio/")
142
  async def upload_audio(file: UploadFile = File(...)):
143
  try:
144
- # Read the uploaded file
145
  audio_data = await file.read()
146
 
147
- # Convert the audio file to the appropriate format for processing
148
  audio_segment = AudioSegment.from_file(io.BytesIO(audio_data), format=file.filename.split('.')[-1])
149
  wav_io = io.BytesIO()
150
  audio_segment.export(wav_io, format="wav")
151
  wav_io.seek(0)
152
  audio, sr = sf.read(wav_io, dtype='float32')
153
 
154
- # If audio has more than one channel, average them
155
  if audio.ndim > 1:
156
  audio = np.mean(audio, axis=1)
157
 
158
- # Extract features
159
  features = extract_features(audio)
160
  features = scaler.transform(features.reshape(1, -1))
161
 
162
- # Predict using the loaded model
163
  prediction = model.predict(features)
164
  is_fake = prediction[0]
165
  result = 'fake' if is_fake else 'real'
 
141
  @app.post("/upload_audio/")
142
  async def upload_audio(file: UploadFile = File(...)):
143
  try:
144
+
145
  audio_data = await file.read()
146
 
 
147
  audio_segment = AudioSegment.from_file(io.BytesIO(audio_data), format=file.filename.split('.')[-1])
148
  wav_io = io.BytesIO()
149
  audio_segment.export(wav_io, format="wav")
150
  wav_io.seek(0)
151
  audio, sr = sf.read(wav_io, dtype='float32')
152
 
 
153
  if audio.ndim > 1:
154
  audio = np.mean(audio, axis=1)
155
 
 
156
  features = extract_features(audio)
157
  features = scaler.transform(features.reshape(1, -1))
158
 
 
159
  prediction = model.predict(features)
160
  is_fake = prediction[0]
161
  result = 'fake' if is_fake else 'real'