You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I attempted to utilize the SpeechRecognition library on a Raspberry Pi to develop a speech recognition project. Whenever I call the Microphone() resource within a subprocess (whether it's a static method or an instance), the program crashes immediately after the subprocess ends(Or crashes after encountering time.sleep() in the main function), triggering a segmentation fault.(Furthermore, the Python interpreter did not provide any stack trace, only the word 'Segmentation fault'. I am not certain if it is an error reported by the Python interpreter.) However, if I only capture data using Microphone() in the main thread and process the data in a subprocess, there are no issues.
This issue is suspected to be related to the Raspberry Pi hardware and the operating system, as it only occurs when running on a Raspberry Pi. Running the same code segment on a personal computer with the Windows operating system does not result in any errors (with the same Python version and libraries).
Detailed code
import time
import threading
import speech_recognition as sr
def threaded_test1():
print(sr.Microphone.list_microphone_names())
time.sleep(5)
def threaded_test2(source):
with source as s:
pass
time.sleep(5)
if __name__ == '__main__':
m = sr.Microphone()
#"Both thread test1 and thread test2 trigger a segmentation fault
sub_thread = threading.Thread(target=threaded_test1)
# sub_thread = threading.Thread(target=threaded_test2,args=(m,))
sub_thread.start()
sub_thread.join()
print("test")
time.sleep(1)
print("over")
Screenshot of the error(Although the error message includes warnings about ALSA, the same warnings are also present when the program runs normally. Therefore, I don't believe they are related to the ALSA warnings.)
Expected behaviour
The program just needs to end correctly.
Actual behaviour
When the program runs to the end of the subprocess that calls the Microphone resource, if the subsequent code in the main thread contains the time.sleep() function, it will crash when it runs to the time.sleep() function, not executing subsequent code, and printing "Segmentation fault" on the screen. (If the subsequent code in the main thread does not contain time.sleep(), it will still trigger a Segmentation fault after the entire program finishes running.)
The stack trace results and thread information from debugging with GDB.(Python interpreter did not provide any stack trace)
Thread 9 "python" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb4ad8440 (LWP 29397)]
0xb0df2b68 in ?? ()
(gdb) backtrace
#0 0xb0df2b68 in ?? ()
#1 0xb6f7f164 in __nptl_deallocate_tsd () at pthread_create.c:301
#2 0xb6f7f310 in start_thread (arg=0xb4ad8440) at pthread_create.c:488
#3 0xb6e12208 in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:73 from /lib/arm-linux-gnueabihf/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) info threads
Id Target Id Frame
1 Thread 0xb6ff7980 (LWP 29352) "python" 0x000bcca0 in ?? ()
* 9 Thread 0xb4ad8440 (LWP 29397) "python" (Exiting) 0xb0df2b68 in ?? ()
System information
My system is <Raspbian GNU/Linux 11>.
My Python version is <Python 3.9.2>.
My SpeechRecognition library version is <3.10.4>.
My PyAudio library version is < 0.2.14>
The text was updated successfully, but these errors were encountered:
Steps to reproduce
I attempted to utilize the SpeechRecognition library on a Raspberry Pi to develop a speech recognition project. Whenever I call the Microphone() resource within a subprocess (whether it's a static method or an instance), the program crashes immediately after the subprocess ends(Or crashes after encountering time.sleep() in the main function), triggering a segmentation fault.(Furthermore, the Python interpreter did not provide any stack trace, only the word 'Segmentation fault'. I am not certain if it is an error reported by the Python interpreter.) However, if I only capture data using Microphone() in the main thread and process the data in a subprocess, there are no issues.
This issue is suspected to be related to the Raspberry Pi hardware and the operating system, as it only occurs when running on a Raspberry Pi. Running the same code segment on a personal computer with the Windows operating system does not result in any errors (with the same Python version and libraries).
Detailed code
Screenshot of the error(Although the error message includes warnings about ALSA, the same warnings are also present when the program runs normally. Therefore, I don't believe they are related to the ALSA warnings.)
Expected behaviour
The program just needs to end correctly.
Actual behaviour
When the program runs to the end of the subprocess that calls the Microphone resource, if the subsequent code in the main thread contains the time.sleep() function, it will crash when it runs to the time.sleep() function, not executing subsequent code, and printing "Segmentation fault" on the screen. (If the subsequent code in the main thread does not contain time.sleep(), it will still trigger a Segmentation fault after the entire program finishes running.)
The stack trace results and thread information from debugging with GDB.(Python interpreter did not provide any stack trace)
System information
My system is <Raspbian GNU/Linux 11>.
My Python version is <Python 3.9.2>.
My SpeechRecognition library version is <3.10.4>.
My PyAudio library version is < 0.2.14>
The text was updated successfully, but these errors were encountered: