- handlers: Contains HTTP handlers that manage API endpoints.
- helpers: Provides utility functions, including text cleaning operations.
- loader: Responsible for loading and parsing utterance files.
- processor: Processes the utterances by cleaning and merging them.
- middleware: Contains middleware functions, including CORS configuration.
- models: Defines the data structures used across the application.
- main.go: The entry point of the application, setting up the server and routes.
func TranscriptHandler(w http.ResponseWriter, r *http.Request)- Description: Handles the HTTP request to process and return a transcript of processed utterances.
-
func CleanText(text string) string- Description: Applies various cleaning functions to the input text, including removing duplicate words and punctuation.
-
func RemoveDuplicateWords(text string) string- Description: Removes consecutive duplicate words from the input text.
-
func RemoveDuplicatePunctuation(text string) string- Description: Removes consecutive duplicate punctuation from the input text.
func LoadUtterances(dir string) ([]models.Utterance, error)- Description: Reads and parses utterance files from the given directory, returning a slice of utterances.
-
func ProcessUtterances(utterances []models.Utterance) ([]models.Utterance, error)- Description: Processes a slice of utterances by cleaning and merging them, based on defined logic.
-
func MergeUtterances(utterances []models.Utterance) ([]models.Utterance, error)- Description: Combines consecutive utterances by the same speaker when appropriate, based on timing and content.
-
func shouldMergeWithPreviousUtterance(prev, current models.Utterance) bool- Description: Determines if the current utterance should be merged with the previous one, based on timing, speaker, and punctuation.
-
func startsWithLowercase(text string) bool- Description: Checks if the first character of the text is a lowercase letter.
func CorsMiddleware(next http.Handler) http.Handler- Description: Adds basic CORS headers to responses, allowing for cross-origin requests.
-
Utterance Struct
- Description: Represents a segment of speech in a transcript, containing details such as speaker, text, and timestamps.
-
Transcript Struct
- Description: Aggregates multiple
Utteranceinstances, representing a complete transcript.
- Description: Aggregates multiple
Modify the directory path in handlers/handlers.go according to your local setup for your utterances folder:
Currently it is set to:
dir := "/Users/dominic/Desktop/golang/transcriptprocessor/utterances"Please set it to:
dir := "Your/Absolute/Directory/Path/to/utterances"- Navigate to the backend directory within the project structure.
- Run
go mod tidyto ensure all dependencies are correctly installed. - Execute
go run main.goto start the server. By default, it will listen onlocalhost:8080. - The server routes are configured to respond to API requests. Use
/api/transcriptto fetch processed transcripts.
- Comprehensive tests are available for each package. To run tests, execute
go test -v ./...at the root of the backend directory. This command recursively runs all tests. - For individual packages, navigate to the package directory and run
go test.
- src: Source directory containing React components and TypeScript types.
- public: Contains static files like HTML entry point and icons.
- .env: Environment file to configure the backend API URL.
App.tsx: The main React component that fetches and displays utterance data from the backend.types.ts: TypeScript definitions for the data structures used in the frontend.
- Navigate to the frontend directory and run
npm installto install dependencies. - Start the application with
npm start. This will launch the app in your default web browser atlocalhost:3000. - The application will automatically connect to the backend API to fetch and display transcripts.
- The
.envfile in the frontend directory specifies the backend API URL. Adjust theREACT_APP_BACKEND_URLvariable as needed to point to your backend server.