python - Kivy Won't Update Label While Reading from Microphone Using PyAudio -


i trying update label in kivy when program recording audio. having problem pyaudio part takes on thread , text sent before record label doesn't update.

update: text "recording..." not appearing on label.

here code (that doesn't update):

self.answer.text = "recording..."  lib.record.record_audio() self.answer.text = "converting text..." 

and using standard pyaudio recording:

import pyaudio import wave  def record_audio():     chunk = 1024     format = pyaudio.paint16     channels = 1     rate = 44100     record_seconds = 5     wave_output_filename = "output.wav"      p = pyaudio.pyaudio()      stream = p.open(format=format,                     channels=channels,                     rate=rate,                     input=true,                     frames_per_buffer=chunk)      print("* recording")      frames = []      in range(0, int(rate / chunk * record_seconds)):         data = stream.read(chunk)         frames.append(data)      print("* done recording")      stream.stop_stream()     stream.close()     p.terminate()      wf = wave.open(wave_output_filename, 'wb')     wf.setnchannels(channels)     wf.setsampwidth(p.get_sample_size(format))     wf.setframerate(rate)     wf.writeframes(b''.join(frames))     wf.close() 

thanks

update: including full class call

the function in question:

def record_clicked(self, btn):     self.answer.text = "recording..."    #doesn't display     # uncomment below line input new wave file      lib.record.record_audio()    #takes 5 seconds     self.answer.text = "converting text..."    #doesn't display     analyzed_tuple = lib.record.analyze_audio()   #takes around ten seconds     self.answer.text = analyzed_tuple[1]    #displays     self.search.text = analyzed_tuple[0] 

where called:

    record_button = button(text="rec.", size_hint=(0.15, 1))     record_button.bind(on_press=self.record_clicked)     top_layout.add_widget(record_button) 


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -