Closed lostmygithubaccount closed 8 months ago
this might already be fixed on main
?
or rather it's an openai version issue...
if you just pass kwargs
through on this line, it works: https://github.com/openai/openai-python/blob/main/src/openai/resources/audio/speech.py#L127
which seems to be how it was on older versions of openai
. but if I upgrade and try to use marvin
I'm hitting other issues
so if I go back to openai==1.13.4
, I get an error: ImportError: cannot import name 'AssistantEventHandler' from 'openai'
if I go above openai==1.14.0
I get the above error
this is very annoying (on OpenAI Python SDK's part, not Marvin) but I'm unblocked I suppose by just patching openai
to add (back?) the **kwargs
input, not sure how y'all would want to handle all these breaking changes they seem to make in minor versions :)
hey @lostmygithubaccount - thanks for the issue
hmmm - I almost wonder if this is a settings prefix issue again
if you just open ipython where you see the error and do something like
import marvin
marvin.settings.openai.audio.speech.model_dump()
do you have a setting in there named openai_api_key
?
I have both marvin_openai_api_key
and openai_api_key
set (to the same value)
woof, yeah. if you're willing to try a little surgery, I bet if you go here and make this
class OpenAISettings(MarvinSettings):
model_config = SettingsConfigDict(
env_prefix="marvin_openai_",
extra="ignore" # add this line
)
...
that this would work
undoing my openai
hack and adding that, I still get:
TypeError: AsyncSpeech.create() got an unexpected keyword argument 'openai_api_key'
hmm, so I can repro, do you have your api key set in some .env
file? or where is it coming from
oops hold on, speech settings redefines its own SettingsConfigDict
so it doesnt inherit from OpenAISettings
try
class SpeechSettings(MarvinSettings):
"""Settings for OpenAI's speech API.
Attributes:
model: The default speech model to use, defaults to `tts-1-hd`.
voice: The default voice to use, defaults to `echo`.
response_format: The default response format to use, defaults to `mp3`.
speed: The default speed to use, defaults to `1.0`.
"""
model_config = SettingsConfigDict(
env_prefix="marvin_speech_", extra="ignore",
)
model: str = Field(
default="tts-1-hd",
description="The default model to use.",
)
voice: Literal["alloy", "echo", "fable", "onyx", "nova", "shimmer"] = Field(
default="echo",
)
response_format: Literal["mp3", "opus", "aac", "flac"] = Field(default="mp3")
speed: float = Field(default=1.0)
I reproduced and this solves for me
@lostmygithubaccount if you can confirm this works for you, I can get this released momentarily
@zzstoatzz that fixed it, appreciate the quick turnaround! installed from the PR and re-ran
oh and I'm setting environment variables in ~/.marvin/.env
First check
Bug summary
trying either example on the docs here: https://www.askmarvin.ai/docs/audio/speech
leads to a traceback:
Reproduction
Error
Versions
Additional context
No response