Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
実践 Realtime API 〜入力として音声データを扱う〜
Search
RioFujimon
November 13, 2024
Programming
1
95
実践 Realtime API 〜入力として音声データを扱う〜
Sansan × YUMEMI iOS ランチタイム LT での発表資料
RioFujimon
November 13, 2024
Tweet
Share
More Decks by RioFujimon
See All by RioFujimon
Foundation Models を 活用するための Tips
riofujimon
1
310
2025.01.17_Sansan × DMM.swift
riofujimon
3
890
Realtime API 入門
riofujimon
0
360
Let's learn code review
riofujimon
3
1.2k
Other Decks in Programming
See All in Programming
PC-6001でPSG曲を鳴らすまでを全部NetBSD上の Makefile に押し込んでみた / osc2025hiroshima
tsutsui
0
200
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
930
AtCoder Conference 2025
shindannin
0
890
Cap'n Webについて
yusukebe
0
160
Vibe codingでおすすめの言語と開発手法
uyuki234
0
160
Python札幌 LT資料
t3tra
7
1.1k
大規模Cloud Native環境におけるFalcoの運用
owlinux1000
0
240
gunshi
kazupon
1
140
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
430
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
210
Claude Codeの「Compacting Conversation」を体感50%減! CLAUDE.md + 8 Skills で挑むコンテキスト管理術
kmurahama
1
700
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
2k
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.3k
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
250
Documentation Writing (for coders)
carmenintech
77
5.2k
Paper Plane (Part 1)
katiecoart
PRO
0
2.7k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
130
Technical Leadership for Architectural Decision Making
baasie
0
200
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
180
The Cult of Friendly URLs
andyhume
79
6.7k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
1
340
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
690
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
120
Transcript
実践 Realtime API 〜入力として音声データを扱う〜 技術本部 Eight Engineering Unit 藤門 莉生
自己紹介 藤門 莉生(Rio Fujimon) - Sansan株式会社 - 23卒(新卒2年目) - Eight
の iOSアプリを開発 - X(旧 Twitter):@RioFujimon - iOS開発で主に興味がある領域 - UIKit, SwiftUI - Bluetooth, NFC, Audio, etc
Realtime API https://openai.com/index/introducing-the-realtime-api/
Realtime API 紹介 開発者はアプリケーションに 高速な音声合成体験 を組み込めるようになった
Realtime API を利用するメリット Whisper 音声を テキストに 書き起こす テキスト 解析モデル 目的の
応答を生成 Realtime API
Kanagawa.swift で話した内容 目的の 応答を生成 Realtime API https://speakerdeck.com/riofujimon/realtime-api-ru-men 👇以下でスライドを公開中 👇 Swift
で Realtime API を扱う基本を中心に話した
本日話す内容 目的の 応答を生成 Realtime API 音声データを Realtime API への入力として扱う方法を話す
Realtime API Sample App
実装を見ていく
https://platform.openai.com/docs/guides/realtime#audio-formats
💡 要点 - 24kHz, PCM16 の 形式に変換処理を 実施して出力する
💡 要点 - AVAudioSession を 設定し、有効化する
👀 AVAudioPCMBuffer のプロパティを表示してみる
💡 要点 - デフォルトでは、 48kHz, 32 bit の形式 - Int16
の値は、nil
💡 要点(⭐⭐⭐) 1. AVAudioFormat で24kHz, 16 bit の形式を 作成する 2.
指定の形式に変換するための Converter を 作成する 3. 形式変換後の AVAudioPCMBuffer を 準備する 4. Converter で 変換して AVAudioPCMBuffer に格納する 5. 16bit の値を取得する
👀 変換後のAVAudioPCMBuffer のプロパティを表示してみる
目的の形式( 16bit PCM Audio, 24kHz, 1channel)に変換完了 🎉
💡 要点 - AVAudioEngine を起動する - AVAudioEngine, Stream を停止する
💡 要点 - 外部への公開メソッドは 2つのみ - startStreaming() -> AsyncStream<Data> -
Data 型に変換した PCM16 形式の 音声データを流す - stopStreaming()
💡 要点 - startStreaming() -> AsyncStream<Data> を呼び出してストリーミングを開始する - Data 型に変換した
PCM16 形式の 音声データを取得する - APIClient の sendAudioBuffer(_: Data) で Realtime API に音声データを送信 - stopStreaming() でストリーミングを 停止する
💡 要点 - Client Event を作成 - 音声データを送信時は、以下 2つを 指定する
- type: input_audio_buffer.append - audio: 24kHz, PCM16, base64エン コードされた音声データの文字列 - WebSocket を利用して Client Event を 送信する ※ 補足 ( https://platform.openai.com/docs/guides/realtime#server-vad-mode ) - Realtime API では、VAD(Voice Activity Detection) がデフォルトで有効
今後お話する内容 目的の 応答を生成 Realtime API Realtime API からのレスポンスをを音声としてリアルタイム再生する
Thank You For Listening