An open API service indexing awesome lists of open source software.

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 -

Awesome Lists containing this project

README

          


Demo Banner

# πŸ“š 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

![Badge](https://img.shields.io/badge/Status-Important-red)
### βœ… 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

![Badge](https://img.shields.io/badge/Model-Whisper_AI-blue)
### βœ… 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`?

![Badge](https://img.shields.io/badge/Package-python--multipart-green)
### βœ… 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

![Badge](https://img.shields.io/badge/OpenAI-Version_1+-purple)
### βœ… 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

![Badge](https://img.shields.io/badge/Reference-Quick_Access-orange)

| 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 |