Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ import tempfile
|
|
| 7 |
import os
|
| 8 |
import soundfile as sf
|
| 9 |
from spellchecker import SpellChecker
|
|
|
|
| 10 |
|
| 11 |
# Check if CUDA is available and set the device
|
| 12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
@@ -87,9 +88,12 @@ def transcribe_video(url):
|
|
| 87 |
audio_bytes = download_audio_from_url(url)
|
| 88 |
print(f"Successfully downloaded {len(audio_bytes)} bytes of audio data")
|
| 89 |
|
| 90 |
-
#
|
|
|
|
|
|
|
|
|
|
| 91 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as temp_audio:
|
| 92 |
-
temp_audio.
|
| 93 |
temp_audio_path = temp_audio.name
|
| 94 |
|
| 95 |
print("Starting audio transcription...")
|
|
|
|
| 7 |
import os
|
| 8 |
import soundfile as sf
|
| 9 |
from spellchecker import SpellChecker
|
| 10 |
+
from pydub import AudioSegment
|
| 11 |
|
| 12 |
# Check if CUDA is available and set the device
|
| 13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 88 |
audio_bytes = download_audio_from_url(url)
|
| 89 |
print(f"Successfully downloaded {len(audio_bytes)} bytes of audio data")
|
| 90 |
|
| 91 |
+
# Convert audio bytes to AudioSegment
|
| 92 |
+
audio = AudioSegment.from_file(io.BytesIO(audio_bytes))
|
| 93 |
+
|
| 94 |
+
# Save as WAV file
|
| 95 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as temp_audio:
|
| 96 |
+
audio.export(temp_audio.name, format="wav")
|
| 97 |
temp_audio_path = temp_audio.name
|
| 98 |
|
| 99 |
print("Starting audio transcription...")
|