I ran the following code
import sys
import os
import speech3
import record
from llama_cpp import Llama
from gradio_client import Client
from pydub import AudioSegment
from pydub.playback import play
def my_exception_handler(exc_type, exc_value, traceback):
# Handle the exception here (e.g., print details, log the error)
print(f"An exception occurred: {exc_type}, {exc_value}")
sys.excepthook = my_exception_handler
print(sys.excepthook)
duration = 5 # Recording duration in seconds
sample_rate = 16000 # Sample rate
sample_width = 2
# load the model
print("Loading model...")
speech3.main()
# llm = Llama("llama2.20b.mlewd-remm.gguf_v2.q4_k_m.gguf")
llm = Llama(model_path="Erosumika-7B-v3-0.2-Q6_K-imat.gguf", n_ctx=4048,
last_n_tokens_size=4048)
print("Model loaded.")
x=speech3.transcribe_stream('recorded_audio.wav', sample_rate, sample_width)
output = llm(
x
# max_tokens=200,
# stop=["n", "Question:", "Q:"],
# echo=True
)
client = Client("http://127.0.0.1:7860")
print(client.view_api())
io=client.predict(output, '特别周 Special Week (Umamusume Pretty Derby)', 'English', 1, True, fn_index=2)
play(AudioSegment.from_wav(io[1])) # Play audio and wait for it to finish
# print the output
#text=json.dumps(output[0].choices.text, indent=4)
#data_dict=json.loads(output[0].choices.text)
def main():
print(output["choices"][0]["text"])
if __name__ == "__main__":
main()
#exec('arduino-cli core serial monitor --board esp32:esp32:esp32-devKit --port usb0 --baud-rate 9600')
Then the got the following output
<function my_exception_handler at 0x0000024A63B1D160>
Loading model...
Recording...
Recording stopped.
Audio saved to recorded_audio.wav
Speech Recognition could not understand audio
Transcription:
An exception occurred: <class 'OSError'>, [WinError 6] The handle is invalid
I’m not entirely sure what it means by the handle is invalid or how to go about fixing this. Any answers are appreciated. Thank you.
I was expecting for the transcript to be passed down to the ai
New contributor
peteblank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.