mirror of
https://github.com/majmongoose/PageBot.git
synced 2024-11-23 21:08:36 -05:00
Update pagebot.py
This commit is contained in:
parent
df4ca14b9c
commit
d52c40f557
@ -49,7 +49,7 @@ def convert_to_mp4(mp3_file):
|
|||||||
def convert_to_text(mp3_path,mp3_name):
|
def convert_to_text(mp3_path,mp3_name):
|
||||||
print(mp3_path)
|
print(mp3_path)
|
||||||
try:
|
try:
|
||||||
command = f'ffmpeg -i "{mp3_path}" {mp3_name}.wav'
|
command = f'ffmpeg -i "{mp3_path}" "{mp3_name}".wav'
|
||||||
subprocess.run(command, shell=True)
|
subprocess.run(command, shell=True)
|
||||||
r = sr.Recognizer()
|
r = sr.Recognizer()
|
||||||
# Load the audio file
|
# Load the audio file
|
||||||
@ -57,7 +57,7 @@ def convert_to_text(mp3_path,mp3_name):
|
|||||||
data = r.record(source)
|
data = r.record(source)
|
||||||
# Convert speech to text
|
# Convert speech to text
|
||||||
text = r.recognize_google(data)
|
text = r.recognize_google(data)
|
||||||
os.remove("{mp3_name}.wav")
|
os.remove(f"{mp3_name}.wav")
|
||||||
return (text)
|
return (text)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error during conversion: {e}")
|
print(f"Error during conversion: {e}")
|
||||||
|
Loading…
Reference in New Issue
Block a user