Skip to content

Commit

Permalink
dont resample, since input is now 16 kHz
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewkennedy5 committed Feb 22, 2024
1 parent dd10292 commit f5658ce
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions openduck-py/openduck_py/routers/voice.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import re
from tempfile import NamedTemporaryFile
from fastapi import APIRouter, Depends, Query, WebSocket
from fastapi import APIRouter, Depends, WebSocket
from sqlalchemy import select
import whisper
from time import time
from torchaudio.functional import resample

import numpy as np
from asgiref.sync import sync_to_async
import torch
from torchaudio.functional import resample
from nemo_text_processing.text_normalization.normalize import Normalizer

from openduck_py.models import DBChatHistory
Expand All @@ -24,10 +21,8 @@


def _transcribe(audio_data):
resampled = resample(
torch.tensor(audio_data).to("cuda"), orig_freq=24000, new_freq=16000
)
return model.transcribe(resampled)["text"]
audio_tensor = torch.tensor(audio_data).to("cuda")
return model.transcribe(audio_tensor)["text"]


_async_transcribe = sync_to_async(_transcribe)
Expand Down

0 comments on commit f5658ce

Please sign in to comment.