hello! I'm trying to implement voice recording for android and I'm working with the PLYER library but it doesn't seem to work. I'm trying to test with the library but I get an error like the following:
from kivy.app import App
from kivy.lang import Builder
from kivy.properties import NumericProperty
from kivy.properties import ObjectProperty
from kivy.uix.boxlayout import BoxLayout
Builder.load_string('''
#:import audio_player plyer.audio
<AudioInterface>:
audio: audio_player
orientation: 'vertical'
padding: '50dp'
spacing: '20dp'
Label:
id: state_label
size_hint_y: None
height: sp(40)
text: 'AudioPlayer State: ' + str(root.audio.state)
Label:
id: location_label
size_hint_y: None
height: sp(40)
text: 'Recording Location: ' + str(root.audio.file_path)
Button:
id: record_button
text: 'Start Recording'
on_release: root.start_recording()
Button:
id: play_button
text: 'Play'
on_release: root.play_recording()
''')
class AudioInterface(BoxLayout):
'''Root Widget.'''
audio = ObjectProperty()
time = NumericProperty(0)
has_record = False
def start_recording(self):
state = self.audio.state
if state == 'ready':
self.audio.start()
if state == 'recording':
self.audio.stop()
self.has_record = True
self.update_labels()
def play_recording(self):
state = self.audio.state
if state == 'playing':
self.audio.stop()
else:
self.audio.play()
self.update_labels()
def update_labels(self):
record_button = self.ids['record_button']
play_button = self.ids['play_button']
state_label = self.ids['state_label']
state = self.audio.state
state_label.text = 'AudioPlayer State: ' + state
play_button.disabled = not self.has_record
if state == 'ready':
record_button.text = 'Start Recording'
if state == 'recording':
record_button.text = 'Press to Stop Recording'
play_button.disabled = True
if state == 'playing':
play_button.text = 'Stop'
record_button.disabled = True
else:
play_button.text = 'Press to play'
record_button.disabled = False
class AudioApp(App):
def build(self):
return AudioInterface()
def on_pause(self):
return True
if __name__ == "__main__":
AudioApp().run()
File "C:\Users\FREDDY\AppData\Roaming\Python\Python310\site-packages\kivy\app.py", line 956, in run
runTouchApp()
File "C:\Users\FREDDY\AppData\Roaming\Python\Python310\site-packages\kivy\base.py", line 574, in runTouchApp
EventLoop.mainloop()
File "C:\Users\FREDDY\AppData\Roaming\Python\Python310\site-packages\kivy\base.py", line 339, in mainloop
self.idle()
File "C:\Users\FREDDY\AppData\Roaming\Python\Python310\site-packages\kivy\base.py", line 383, in idle
self.dispatch_input()
File "C:\Users\FREDDY\AppData\Roaming\Python\Python310\site-packages\kivy\base.py", line 334, in dispatch_input
post_dispatch_input(*pop(0))
File "C:\Users\FREDDY\AppData\Roaming\Python\Python310\site-packages\kivy\base.py", line 302, in post_dispatch_input
wid.dispatch('on_touch_up', me)
File "kivy\_event.pyx", line 731, in kivy._event.EventDispatcher.dispatch
File "C:\Users\FREDDY\AppData\Roaming\Python\Python310\site-packages\kivy\uix\behaviors\button.py", line 179, in on_touch_up
self.dispatch('on_release')
File "kivy\_event.pyx", line 727, in kivy._event.EventDispatcher.dispatch
File "kivy\_event.pyx", line 1307, in kivy._event.EventObservers.dispatch
File "kivy\_event.pyx", line 1191, in kivy._event.EventObservers._dispatch
File "C:\Users\FREDDY\AppData\Roaming\Python\Python310\site-packages\kivy\lang\builder.py", line 55, in custom_callback
exec(__kvlang__.co_value, idmap)
File "<string>", line 22, in <module>
File "d:\PYTHON\ParaTesis\plyer\plyer-master\examples\audio\main.py", line 50, in start_recording
self.audio.start()
File "C:\Users\FREDDY\AppData\Roaming\Python\Python310\site-packages\plyer\facades\audio.py", line 67, in start
self._start()
File "C:\Users\FREDDY\AppData\Roaming\Python\Python310\site-packages\plyer\platforms\win\audio.py", line 330, in _start
open_params = send_command(
File "C:\Users\FREDDY\AppData\Roaming\Python\Python310\site-packages\plyer\platforms\win\audio.py", line 128, in send_command
error_code = send_command_w(
OSError: exception: access violation reading 0xFFFFFFFFFFFFFFFF
THANK YOU VERY MUCH FOR YOUR HELP