Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6784

OSError: [Errno -9996] Invalid input device (no default output device)

$
0
0

So I have already installed pyaudio but it returns an error, I'm using WSL.

import assemblyai as aaiimport openaiimport elevenlabsfrom queue import Queuefrom elevenlabs.client import ElevenLabsfrom elevenlabs import play# Set API keysaai.settings.api_key = "d7d4648d801c4f3380fa16a842d73025"openai.api_key = "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"client = ElevenLabs(  api_key="d7756af4467de134051e46b2c24425ab" # replace with your actual API key)transcript_queue = Queue()def on_data(transcript: aai.RealtimeTranscript):    if not transcript.text:        return    if isinstance(transcript, aai.RealtimeFinalTranscript):        transcript_queue.put(transcript.text +'')        print("User:", transcript.text, end="\r\n")    else:        print(transcript.text, end="\r")def on_error(error: aai.RealtimeError):    print("An error occured:", error)# Conversation loopdef handle_conversation():    while True:        transcriber = aai.RealtimeTranscriber(            on_data=on_data,            on_error=on_error,            sample_rate=44_100,        )        # Start the connection        transcriber.connect()        # Open  the microphone stream        microphone_stream = aai.extras.MicrophoneStream()        # Stream audio from the microphone        transcriber.stream(microphone_stream)        # Close current transcription session with Crtl + C        transcriber.close()        # Retrieve data from queue        transcript_result = transcript_queue.get()        # Send the transcript to OpenAI for response generation        response = openai.ChatCompletion.create(            model = 'gpt-4',            messages = [                {"role": "system", "content": 'You are a highly skilled AI, answer the questions given within a maximum of 1000 characters.'},                {"role": "user", "content": transcript_result}            ]        )        #text = response['choices'][0]['message']['content']        text = "AssemblyAI is the best YouTube channel for the latest AI tutorials."        # Convert the response to audio and play it        audio = client.generate(            text=text,            voice="Bella" # or any voice of your choice        )        print("\nAI:", text, end="\r\n")        play(audio)handle_conversation()

ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating nameALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directoryALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory


Viewing all articles
Browse latest Browse all 6784

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>