-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_audio_format.py
More file actions
48 lines (41 loc) · 1.51 KB
/
Copy pathtest_audio_format.py
File metadata and controls
48 lines (41 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""
Test script to check if the Speech-to-Text API can handle the audio format
"""
import base64
import os
from google.cloud import speech_v1 as speech
# Sample base64 audio (you'll need to get this from your logs or frontend)
# For now, let's just test the API configuration
def test_speech_api():
"""Test Speech-to-Text API configuration"""
try:
client = speech.SpeechClient()
print("✅ Speech-to-Text client initialized successfully")
# Test different configurations
configs_to_test = [
{
"name": "WEBM_OPUS with 16kHz",
"encoding": speech.RecognitionConfig.AudioEncoding.WEBM_OPUS,
"sample_rate": 16000
},
{
"name": "WEBM_OPUS with 48kHz",
"encoding": speech.RecognitionConfig.AudioEncoding.WEBM_OPUS,
"sample_rate": 48000
},
{
"name": "WEBM_OPUS without sample rate",
"encoding": speech.RecognitionConfig.AudioEncoding.WEBM_OPUS,
"sample_rate": None
}
]
for config_test in configs_to_test:
print(f"\n📋 Testing: {config_test['name']}")
print(f" Encoding: {config_test['encoding']}")
print(f" Sample Rate: {config_test['sample_rate']}")
return True
except Exception as e:
print(f"❌ Error: {str(e)}")
return False
if __name__ == "__main__":
test_speech_api()