Ошибка Audio rample: (неверный ввод) Неверная ошибка ввода
код: неверный ввод
Сообщение: ошибка недопустимого ввода < /p>
Я получаю эту ошибку выше при тестировании звука в текст, используя phi-4-modal-instruct в Azure Ai Foundry < /p>
import base64
import os
from azure.ai.inference import ChatCompletionsClient
from azure.ai.inference.models import SystemMessage, UserMessage, TextContentItem, ImageContentItem, AudioContentItem, InputAudio, AudioContentFormat
import io
from azure.core.credentials import AzureKeyCredential
from azure.identity import DefaultAzureCredential
from PIL import Image
# Configuration
ENDPOINT_URL = "https://myaiservices.services.ai.azure.com/models"
MODEL_NAME = "phi-4-multimodal-instruct"
AUDIO_PATH = "harvard.wav" # Path to a sample audio file
def test_audio_prompt(client, audio_path):
"""Test an audio input with a prompt."""
print("\n=== Testing Audio Prompt ===")
try:
# Open and encode the audio file to base64
with open(audio_path, "rb") as audio_file:
base64_audio = base64.b64encode(audio_file.read()).decode("utf-8")
# Prepare the audio content
audio_content = {
"type": "audio",
"audio_data": base64_audio,
"mime_type": "audio/wav"
}
# Make the chat completions request
response = client.complete(
messages=[
SystemMessage(content="You are an AI assistant for translating and transcribing audio clips."),
UserMessage(content=[
TextContentItem(text="Please print this audio snippet."),
audio_content
])
],
model=MODEL_NAME
)
# Print the response
print("Audio Response:", response.choices[0].message.content)
except FileNotFoundError:
print(f"Audio file not found: {audio_path}")
except Exception as e:
print("Audio Prompt Error:", str(e))
def main():
# Initialize the client
client = ChatCompletionsClient(
endpoint=ENDPOINT_URL,
credential=DefaultAzureCredential(),
credential_scopes=["https://cognitiveservices.azure.com/.default"]
)
test_audio_prompt(client, AUDIO_PATH)
if __name__ == "__main__":
main()
Подробнее здесь: https://stackoverflow.com/questions/796 ... ompt-error
Azure AI Services для выпуска PHI-4-модальной инстакции с ошибкой Audio-Audio reffice: (неверный ввод). Неверная ошибка ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Проблема: Ошибка ImportError в Python при использовании библиотеки phi.
Anonymous » » в форуме Python - 0 Ответы
- 22 Просмотры
-
Последнее сообщение Anonymous
-