Comments (3)
No, just leave it as it is. The feed_audio method takes care of the buffer size.
You just need to ensure that the input chunks are PCM raw data and 16000 Hz sample rate:
from scipy.signal import resample
def decode_and_resample(
audio_data,
original_sample_rate,
target_sample_rate):
# Decode 16-bit PCM data to numpy array
audio_np = np.frombuffer(audio_data, dtype=np.int16)
# Calculate the number of samples after resampling
num_original_samples = len(audio_np)
num_target_samples = int(num_original_samples * target_sample_rate /
original_sample_rate)
# Resample the audio
resampled_audio = resample(audio_np, num_target_samples)
return resampled_audio.astype(np.int16).tobytes()
resampled_chunk = decode_and_resample(chunk, sample_rate, 16000)
recorder.feed_audio(resampled_chunk)
from realtimestt.
Thanks! Can feed_audio with 16k stereo data?the raw data is 48k,stereo data,when i call decode_and_resample,the audio data is 16k stereo.
In my realtime server,I can not get recorder.text() in a loop by using thread,may be the feed data is not correct.
from realtimestt.
Should be mono 16000 Hz, 16 Bit, PCM
from realtimestt.
Related Issues (20)
- Example for using remote GPU server? HOT 1
- [Feature request] Update porcupine version for use with macOS arm HOT 2
- transcribing multiple audio streams simultaneously HOT 2
- [Feature Request] Custom wakeword file HOT 2
- No Internet Connection HOT 4
- How to choose the CUDA version?
- How to choose the CUDA version? HOT 2
- the on_realtime_transcription_update text issue HOT 3
- CUDA initialization error on current master HOT 1
- Porcupine integration on Mac HOT 1
- pyaudio Invalid number of channels HOT 1
- Float 16 to Float 32 quantization HOT 19
- recorder.text(process_text) does not stop recording HOT 6
- Support GPT-SoVITS TTS
- Passing audio bytes (Frames) to the AudioToTextRecorder HOT 10
- Multiple clients in browser-client code HOT 3
- How to calculate the latency of STT
- Syntax error line 520 audio_recorder.py HOT 3
- An attempt has been made to start a new process before the current process has finished its bootstrapping phase HOT 1
- how about the qulity of the batched faster-whisper? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from realtimestt.