I am getting this error using google gemini apis (I think that’s because of the file size, but I’m not sure, and I don’t know how to fix it): ssl.SSLWantWriteError: The operation did not complete (write) (_ssl.c:2384)
.
Using a dirrefent file extension (mp3 instead of m4a), i get this different error: return self._sslobj.write(data)n TimeoutError: The write operation timed out
Here’s the code:
import google.generativeai as genai
genai.configure(api_key=MY_API_KEY)
filePath = AUDIO_FILE_PATH
generation_config = {
"temperature": 1,
"top_p": 0.95,
"top_k": 0,
"max_output_tokens": 8192,
}
safety_settings = [
{
"category": "HARM_CATEGORY_HARASSMENT",
"threshold": "BLOCK_NONE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"threshold": "BLOCK_NONE"
},
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "BLOCK_NONE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_NONE"
},
]
audioFile = genai.upload_file(path = filePath, display_name = "audio_file")
model = genai.GenerativeModel(model_name="gemini-1.5-pro-latest",
generation_config=generation_config,
safety_settings=safety_settings)
response = model.generate_content(["summarize this audio", audioFile])
print(response.text)
I saw this could be a problem with ssl upload, but couldn’t find how to fix it on this specific case.