ciyidogan commited on
Commit
bdda7c9
·
verified ·
1 Parent(s): ae45ffa

Update stt/stt_google.py

Browse files
Files changed (1) hide show
  1. stt/stt_google.py +34 -0
stt/stt_google.py CHANGED
@@ -142,6 +142,40 @@ class GoogleSTT(STTInterface):
142
  # ✅ WAV formatında gönder - Google bu formatı daha iyi tanıyor
143
  wav_audio = self._convert_to_wav_proper(audio_data, config.sample_rate)
144
  log_info(f"🔧 WAV conversion: {len(audio_data)} PCM → {len(wav_audio)} WAV")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
 
146
  # Configure recognition
147
  language_code = self._map_language_code(config.language)
 
142
  # ✅ WAV formatında gönder - Google bu formatı daha iyi tanıyor
143
  wav_audio = self._convert_to_wav_proper(audio_data, config.sample_rate)
144
  log_info(f"🔧 WAV conversion: {len(audio_data)} PCM → {len(wav_audio)} WAV")
145
+
146
+ import tempfile
147
+ import os
148
+
149
+ # Raw PCM kaydet
150
+ pcm_file = tempfile.mktemp(suffix='.pcm')
151
+ with open(pcm_file, 'wb') as f:
152
+ f.write(audio_data)
153
+ log_info(f"🔍 Raw PCM saved to: {pcm_file}")
154
+
155
+ # WAV kaydet
156
+ wav_file = tempfile.mktemp(suffix='.wav')
157
+ with open(wav_file, 'wb') as f:
158
+ f.write(wav_audio)
159
+ log_info(f"🔍 WAV saved to: {wav_file}")
160
+
161
+ # Test kodunla aynı şekilde test et
162
+ try:
163
+ import subprocess
164
+ result = subprocess.run([
165
+ 'python', 'app.py', wav_file
166
+ ], capture_output=True, text=True, timeout=30)
167
+ log_info(f"🔍 Test script result: {result.stdout}")
168
+ if result.stderr:
169
+ log_error(f"🔍 Test script error: {result.stderr}")
170
+ except Exception as e:
171
+ log_warning(f"Could not run test script: {e}")
172
+
173
+ # Cleanup files after test
174
+ try:
175
+ os.unlink(pcm_file)
176
+ os.unlink(wav_file)
177
+ except:
178
+ pass
179
 
180
  # Configure recognition
181
  language_code = self._map_language_code(config.language)