chengsokdara / use-whisper

React hook for OpenAI Whisper with speech recorder, real-time transcription, and silence removal built-in
MIT License
735 stars 139 forks source link

Support private deployed whisper service #41

Closed huajianmao closed 1 year ago

huajianmao commented 1 year ago

Recently, I'm working on a repo which provides openai compatible APIs for LLM and whisper model. And I want to use this awesome use-whisper project in my app with my own deployed whisper service.

The openai package supports setting apiBase with openai.api_base = "http://localhost:8000/api/v1" to use other openai services like Azure OpenAI services.

It might be better to support apiBase configuration to enhance this awesome project.

With this PR, we can use this repo with a private whisper service.

import { useWhisper } from '@chengsokdara/use-whisper'

const App = () => {
  const {
    recording,
    speaking,
    transcribing,
    transcript,
    pauseRecording,
    startRecording,
    stopRecording,
  } = useWhisper({
    apiKey: 'none',
    apiBase: 'http://localhost:8000/api/v1'
  })

  return (
    <div>
      <p>Recording: {recording}</p>
      <p>Speaking: {speaking}</p>
      <p>Transcribing: {transcribing}</p>
      <p>Transcribed Text: {transcript.text}</p>
      <button onClick={() => startRecording()}>Start</button>
      <button onClick={() => pauseRecording()}>Pause</button>
      <button onClick={() => stopRecording()}>Stop</button>
    </div>
  )
}
huajianmao commented 1 year ago

Oh, it already supports custom server with onTranscribe.

sorry for this PR.