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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
RioFujimon
November 13, 2024
Programming
100
1
Share
実践 Realtime API 〜入力として音声データを扱う〜
Sansan × YUMEMI iOS ランチタイム LT での発表資料
RioFujimon
November 13, 2024
More Decks by RioFujimon
See All by RioFujimon
Foundation Models を 活用するための Tips
riofujimon
1
350
2025.01.17_Sansan × DMM.swift
riofujimon
3
1.1k
Realtime API 入門
riofujimon
0
370
Let's learn code review
riofujimon
3
1.3k
Other Decks in Programming
See All in Programming
クラウドネイティブなエンジニアに向ける Raycastの魅力と実際の活用事例
nealle
2
220
AIと共に生きる技術選定 2026
sgash708
0
110
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
660
ハーネスエンジニアリングとは?
kinopeee
13
6.1k
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
610
Vibe NLP for Applied NLP
inesmontani
PRO
0
480
Programming with a DJ Controller — not vibe coding
m_seki
3
170
属人化しないコード品質の作り方_2026.04.07.pdf
muraaano
0
240
YJITとZJITにはイカなる違いがあるのか?
nakiym
0
250
Cache-moi si tu peux : patterns et pièges du cache en production - Devoxx France 2026 - Conférence
slecache
0
300
Agentic Elixir
whatyouhide
0
410
mruby on C#: From VM Implementation to Game Scripting (RubyKaigi 2026)
hadashia
2
630
Featured
See All Featured
Balancing Empowerment & Direction
lara
6
1.1k
Color Theory Basics | Prateek | Gurzu
gurzu
0
300
Chasing Engaging Ingredients in Design
codingconduct
0
170
Building Applications with DynamoDB
mza
96
7k
Into the Great Unknown - MozCon
thekraken
41
2.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
Making the Leap to Tech Lead
cromwellryan
135
9.8k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
Prompt Engineering for Job Search
mfonobong
0
280
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