프로그램 사용/ai 프로그램
openai api .. 오디오 처리 성공
구차니
2026. 5. 7. 18:10
다시 해보니 telegram은 ogg로 보내는데 이걸 넣으면 wav가 아니라서 배째는거라
ffmpeg을 통해서 ogg를 wav로 바꾸고 하니 먼가 처리를 한다.
다만 소리 크기가 작아서 인가 은근히 인식율이 떨이지네.. (gemma4:e2b)
----
ollama 통해서 하고 있는데 미구현인가..
아니면 gemma4:e2b가 ollama에서 할 때 오디오는 미지원인건가... 이건 어떻게 확인하지?
그 와중에 왜 이미지로 인식하냐?
| --- [Prompt to AI] (Model: gemma4:e2b) --- [{'role': 'user', 'content': [{'type': 'text', 'text': '이 내용을 분석해줘'}, {'type': 'input_audio', 'input_audio': {'data': 'encoded data', 'format': 'wav'}}]}] {'error': {'message': 'Failed to create new sequence: failed to process inputs: image: unknown format', 'type': 'api_error', 'param': None, 'code': None}} |
| $ ollama show gemma4:e2b Model architecture gemma4 parameters 5.1B context length 131072 embedding length 1536 quantization Q4_K_M requires 0.20.0 Capabilities completion vision audio tools thinking Parameters temperature 1 top_k 64 top_p 0.95 License Apache License Version 2.0, January 2004 ... |
| import OpenAI from "openai"; const openai = new OpenAI(); // Fetch an audio file and convert it to a base64 string const url = "https://cdn.openai.com/API/docs/audio/alloy.wav"; const audioResponse = await fetch(url); const buffer = await audioResponse.arrayBuffer(); const base64str = Buffer.from(buffer).toString("base64"); const response = await openai.chat.completions.create({ model: "gpt-audio", modalities: ["text", "audio"], audio: { voice: "alloy", format: "wav" }, messages: [ { role: "user", content: [ { type: "text", text: "What is in this recording?" }, { type: "input_audio", input_audio: { data: base64str, format: "wav" }} ] } ], store: true, }); console.log(response.choices[0]); |
[링크 : https://developers.openai.com/api/docs/guides/audio?example=audio-in]