replace wave duration with SOX
This commit is contained in:
parent
d305abe5ae
commit
a73ddf59d1
1 changed files with 245 additions and 239 deletions
|
@ -13,6 +13,7 @@ import faulthandler
|
|||
from zmq.asyncio import Context
|
||||
import zmq
|
||||
import wave
|
||||
import sox
|
||||
from pythonosc import udp_client
|
||||
import random
|
||||
|
||||
|
@ -1418,10 +1419,15 @@ class Story(object):
|
|||
fn = await message.getAudioFilePath()
|
||||
|
||||
# get duration of audio file, so the client can detect a hang of 'play'
|
||||
with wave.open(fn,'r') as fp:
|
||||
frames = fp.getnframes()
|
||||
rate = fp.getframerate()
|
||||
duration = frames/float(rate)
|
||||
|
||||
#old: with wave
|
||||
# with wave.open(fn,'r') as fp:
|
||||
# frames = fp.getnframes()
|
||||
# rate = fp.getframerate()
|
||||
# duration = frames/float(rate)
|
||||
|
||||
# get duration of audio file, new: with sox
|
||||
duration = sox.file_info.duration(fn)
|
||||
|
||||
# self.hugvey.google.pause() # pause STT to avoid text events while decision is made
|
||||
self.hugvey.sendCommand({
|
||||
|
|
Loading…
Reference in a new issue