Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline Audio Doesn't Work #4618

Open
Helw150 opened this issue Nov 6, 2024 · 0 comments
Open

Inline Audio Doesn't Work #4618

Helw150 opened this issue Nov 6, 2024 · 0 comments
Labels
api: vertex-ai Issues related to the googleapis/python-aiplatform API.

Comments

@Helw150
Copy link

Helw150 commented Nov 6, 2024

Environment details

  • OS type and version: Ubuntu on Google Cloud
  • Python version: 3.10.15
  • pip version: 24.2
  • google-cloud-aiplatform version: 1.71.1

Steps to reproduce

  1. Run the Code Listed in the "Provide the audio file as inline data in the request" of the Audio Tutorial
    https://ai.google.dev/gemini-api/docs/audio?lang=python#inline-data

Code example

# Initialize a Gemini model appropriate for your use case.
model = genai.GenerativeModel('models/gemini-1.5-flash')

# Create the prompt.
prompt = "Please summarize the audio."

# Load the samplesmall.mp3 file into a Python Blob object containing the audio
# file's bytes and then pass the prompt and the audio to Gemini.
response = model.generate_content([
    prompt,
    {
        "mime_type": "audio/mp3",
        "data": pathlib.Path('samplesmall.mp3').read_bytes()
    }
])

# Output Gemini's response to the prompt and the inline audio.
print(response.text)

Stack trace

Traceback (most recent call last):
  File "/home/held/audio-arena/test.py", line 9, in <module>
    for tok in stream((t[1], t[0])):
  File "/home/held/audio-arena/src/speech_arena/streaming_helpers.py", line 44, in get_chat_response
    for chunk in responses:
  File "/opt/conda/lib/python3.10/site-packages/vertexai/generative_models/_generative_models.py", line 853, in _generate_content_streaming
    request = self._prepare_request(
  File "/opt/conda/lib/python3.10/site-packages/vertexai/generative_models/_generative_models.py", line 3201, in _prepare_request
    request_v1beta1 = super()._prepare_request(
  File "/opt/conda/lib/python3.10/site-packages/vertexai/generative_models/_generative_models.py", line 506, in _prepare_request
    _validate_generate_content_parameters(
  File "/opt/conda/lib/python3.10/site-packages/vertexai/generative_models/_generative_models.py", line 169, in _validate_generate_content_parameters
    _validate_contents_type_as_valid_sequence(contents)
  File "/opt/conda/lib/python3.10/site-packages/vertexai/generative_models/_generative_models.py", line 220, in _validate_contents_type_as_valid_sequence
    raise TypeError(
TypeError: When passing a list with Content dict objects, every item in a list must be a Content dict object.
@product-auto-label product-auto-label bot added the api: vertex-ai Issues related to the googleapis/python-aiplatform API. label Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vertex-ai Issues related to the googleapis/python-aiplatform API.
Projects
None yet
Development

No branches or pull requests

1 participant