Day 3: Transcribing Voice Memos to Text Using AssemblyAI #VoiceTranscription #AIAssistant

On Day 3, we’ll convert recorded voice memos into text using AssemblyAI. This transcription will later feed GPT, enabling it to generate CRM-ready sales notes.


1. Why Use Transcription?

Automatic Note-Taking – Salespeople speak freely, AI turns it into text.
Foundation for GPT ProcessingGPT can summarize and format transcriptions into CRM entries.
Better Record-Keeping – Stored transcriptions become searchable meeting logs.


2. Why AssemblyAI?

  • Simple REST API.
  • High Accuracy for Sales Calls.
  • Free Trial + Pay-as-You-Go.

Sign up at AssemblyAI and get your API Key.


3. Setting Up AssemblyAI API

Step 1: Create transcriptionService.js

Create src/api/transcriptionService.js:

import axios from 'axios';
import { ASSEMBLYAI_API_KEY } from '@env';

const AssemblyAI_BASE_URL = 'https://api.assemblyai.com/v2';

export const uploadAudio = async (fileUri) => {
    const response = await fetch(fileUri);
    const blob = await response.blob();

    const formData = new FormData();
    formData.append('file', blob, 'audio.m4a');

    const uploadResponse = await axios.post(`${AssemblyAI_BASE_URL}/upload`, formData, {
        headers: {
            'Content-Type': 'multipart/form-data',
            'Authorization': ASSEMBLYAI_API_KEY,
        },
    });

    return uploadResponse.data.upload_url;
};

export const transcribeAudio = async (audioUrl) => {
    const response = await axios.post(
        `${AssemblyAI_BASE_URL}/transcript`,
        { audio_url: audioUrl },
        { headers: { Authorization: ASSEMBLYAI_API_KEY } }
    );

    return response.data.id;
};

export const getTranscriptionResult = async (transcriptId) => {
    const response = await axios.get(`${AssemblyAI_BASE_URL}/transcript/${transcriptId}`, {
        headers: { Authorization: ASSEMBLYAI_API_KEY },
    });

    return response.data;
};

4. Updating Home Screen to Trigger Transcription

Step 1: Modify HomeScreen.js

import React, { useState } from 'react';
import { View, Text, Button, StyleSheet, ActivityIndicator, Alert } from 'react-native';
import VoiceRecorder from '../components/VoiceRecorder';
import { uploadAudio, transcribeAudio, getTranscriptionResult } from '../api/transcriptionService';

export default function HomeScreen() {
    const [recordingUri, setRecordingUri] = useState(null);
    const [transcription, setTranscription] = useState('');
    const [isLoading, setIsLoading] = useState(false);

    const handleRecordingComplete = (uri) => {
        setRecordingUri(uri);
        Alert.alert('Recording Saved', `Saved to: ${uri}`);
    };

    const handleTranscribe = async () => {
        try {
            setIsLoading(true);

            // 1. Upload audio
            const audioUrl = await uploadAudio(recordingUri);

            // 2. Transcribe audio
            const transcriptId = await transcribeAudio(audioUrl);

            // 3. Poll for results
            let status = 'processing';
            let transcriptData = null;

            while (status === 'processing' || status === 'queued') {
                transcriptData = await getTranscriptionResult(transcriptId);
                status = transcriptData.status;

                if (status === 'completed') {
                    setTranscription(transcriptData.text);
                    break;
                } else if (status === 'failed') {
                    Alert.alert('Transcription Failed');
                    break;
                }
                await new Promise((resolve) => setTimeout(resolve, 3000)); // Poll every 3s
            }
        } catch (error) {
            console.error('Transcription Error:', error);
            Alert.alert('Error', 'Failed to transcribe audio');
        } finally {
            setIsLoading(false);
        }
    };

    return (
        <View style={styles.container}>
            <Text style={styles.title}>AI Sales Assistant</Text>
            <VoiceRecorder onRecordingComplete={handleRecordingComplete} />

            {recordingUri && <Button title="Transcribe Memo" onPress={handleTranscribe} />}

            {isLoading && <ActivityIndicator size="large" color="#0000ff" />}
            {transcription ? <Text>Transcription: {transcription}</Text> : null}
        </View>
    );
}

const styles = StyleSheet.create({
    container: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: 10 },
    title: { fontSize: 24, fontWeight: 'bold', marginBottom: 20 },
});

5. Running the App

Step 1: Start the App

npx expo start

Step 2: Test Transcription Flow

ActionExpected Result
Record Voice MemoMemo recorded and URI displayed.
Tap Transcribe MemoUpload → Process → Transcribed text displayed.
Invalid File/Slow UploadDisplays error or “Transcription Failed.”

6. Optional: Show Status Updates

<Text>Status: {status}</Text>

7. Preparing for Tomorrow: GPT Integration

Tomorrow, we’ll:

  • Send the transcription text to GPT.
  • Generate summarized meeting notes and CRM action items.
See also  Day 4: Setting Up Authentication for Users to Log In

8. Key Concepts Covered

✅ Integrated AssemblyAI transcription API.
✅ Uploaded voice memo files for processing.
✅ Displayed transcription result in-app.


9. Next Steps: Generating CRM Notes with GPT

Tomorrow, we’ll:

  • Pass transcription text to GPT-4.
  • Generate meeting summaries & CRM entries.

10. References & Learning Resources


11. SEO Keywords:

React Native voice transcription, AssemblyAI audio transcription API, React Native GPT sales assistant, voice memo to text app, AI-powered sales note automation.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.