https://github.com/sarthak576/internsbyte
YouTube Video Link -
https://github.com/sarthak576/internsbyte
chatbot-application openai-api realistic transcription whisper-api
Last synced: 10 months ago
JSON representation
YouTube Video Link -
- Host: GitHub
- URL: https://github.com/sarthak576/internsbyte
- Owner: sarthak576
- Created: 2025-07-29T06:38:37.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-08T06:33:21.000Z (11 months ago)
- Last Synced: 2025-08-08T08:20:23.289Z (11 months ago)
- Topics: chatbot-application, openai-api, realistic, transcription, whisper-api
- Language: Python
- Homepage: https://youtu.be/4y1a4syMJHM?si=8TMlX0g8loZ3M428
- Size: 292 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π Developer Notes β OpenAI, Whisper AI & More
> π **Future-Proof & Clickable** β This doc is structured for quick navigation, visual clarity, and easy updates.
---
## π Table of Contents
1. [π OpenAI API Key Usage](#-1-openai-api-key-usage)
2. [ποΈ Whisper AI β Speech to Text](#-2-whisper-ai--speech-to-text)
3. [π¦ Why Install `multipart`](#-3-why-install-multipart)
4. [π Using Latest OpenAI Version](#-4-using-latest-openai-version)
5. [β‘ Quick Reference Table](#-quick-reference-table)
---
## π 1. OpenAI API Key Usage

### β
5 Key Points β Using `os.getenv("OPEN_AI_API_KEY")` for API Key:
1. **`os.getenv()` Reads Env Vars** β Fetches `OPEN_AI_API_KEY` from environment variables.
2. **Must Export It π** β Before running:
```bash
export OPEN_AI_API_KEY="your_api_key"
## ποΈ 2. Whisper AI β Speech to Text

### β
5 Key Points β Using Whisper AI with ChatGPT/OpenAI:
1. **What is Whisper? ποΈ** β OpenAIβs automatic speech recognition (ASR) model for converting audio to text.
2. **Usage in Code π»**:
```python
import openai
openai.api_key = "your_api_key"
audio_file = open("your_audio.mp3", "rb")
transcript = openai.Audio.transcribe("whisper-1", audio_file)
print(transcript["text"])
## π¦ 3. Why Install `multipart`?

### β
2 Key Points β `pip install multipart`:
1. **Purpose** β Parses `multipart/form-data` for handling file uploads in FastAPI and similar frameworks.
2. **Example**:
```python
from fastapi import FastAPI, File, UploadFile
app = FastAPI()
@app.post("/upload/")
async def upload(file: UploadFile = File(...)):
return {"filename": file.filename}
## π 4. Using Latest OpenAI Version

### β
5 Key Points β Updating to Latest OpenAI SDK:
1. **API Key Change π** β Old: `openai.apikey` β β New: `OpenAI(api_key=...)` β
2. **File Handling π** β Files are temporarily saved before being sent to the API.
3. **Method Update π οΈ** β Old: `transcribe()` β β New: `client.audio.transcriptions.create(...)` β
4. **FastAPI Integration β‘** β `UploadFile = File(...)` ensures proper `multipart/form-data` handling.
5. **Future-Proofing π** β v1+ syntax prevents deprecation issues and keeps code up-to-date.
## β‘ 5. Quick Reference Table

| Section | Topic | Key Command / Code | Notes |
|---------|-------|-------------------|-------|
| 1 | OpenAI API Key Usage | `export OPEN_AI_API_KEY="your_api_key"` | Set in terminal before running app |
| 2 | Whisper AI β Speech to Text | `openai.Audio.transcribe("whisper-1", audio_file)` | Works with `.mp3`, `.wav`, `.m4a`, etc. |
| 3 | Install `multipart` | `pip install python-multipart` | Needed for file uploads in FastAPI |
| 4 | Latest OpenAI Version | `OpenAI(api_key=...)` & `client.audio.transcriptions.create(...)` | Updated v1+ SDK syntax |