Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop a voice input feature similar to WeChat #228

Open
3 tasks done
jerryokk opened this issue Mar 11, 2023 · 4 comments
Open
3 tasks done

Develop a voice input feature similar to WeChat #228

jerryokk opened this issue Mar 11, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@jerryokk
Copy link

jerryokk commented Mar 11, 2023

Clear and concise description of the problem

Create a voice input feature that allows users to record audio by long-pressing a button for up to 60 seconds. Users can cancel the recording by sliding up and releasing the button to send the audio. After sending the audio, the feature will use OpenAI's audio API to convert the audio into text and send it to ChatGPT.

长按录音,最大录音60s,上滑取消,松手发送。发送后通过 openai 的 audio 接口转成文字发送给 chatgpt api。

Suggested solution

const formData = new FormData();
formData.append("file", audioFile);  // WebM 录制的文件
formData.append("model", model);
formData.append("prompt", prompt);   // 提示中写使用简体中文,否则默认出来的是繁体的
formData.append("response_format", "json");
formData.append("temperature", temperature);
formData.append("language", language);

fetch(BASE_URL + "/v1/audio/transcriptions", {
    method: "POST",
    headers: {
        "Authorization": "Bearer " + API_KEY
    },
    body: formData
})
.then(response => {
    if (!response.ok) {
        throw new Error("HTTP error " + response.status);
    }
    return response.json()
})
.then(json => {
    // 转写的文本在 json.text
})
.catch(error => {
    console.error(error);
});

Alternative

No response

Additional context

OpenAI's audio API charges $0.006 per minute for transcription.

Validations

@jerryokk jerryokk added the enhancement New feature or request label Mar 11, 2023
@jerryokk
Copy link
Author

@yzh990918 Expert, evaluate whether this is an interesting suggestion.

@Root-FTW
Copy link

Clear and concise description of the problem

Create a voice input feature that allows users to record audio by long-pressing a button for up to 60 seconds. Users can cancel the recording by sliding up and releasing the button to send the audio. After sending the audio, the feature will use OpenAI's audio API to convert the audio into text and send it to ChatGPT.

长按录音,最大录音60s,上滑取消,松手发送。发送后通过 openai 的 audio 接口转成文字发送给 chatgpt api。

Suggested solution

const formData = new FormData();
formData.append("file", audioFile);  // WebM 录制的文件
formData.append("model", model);
formData.append("prompt", prompt);   // 提示中写使用简体中文,否则默认出来的是繁体的
formData.append("response_format", "json");
formData.append("temperature", temperature);
formData.append("language", language);

fetch(BASE_URL + "/v1/audio/transcriptions", {
    method: "POST",
    headers: {
        "Authorization": "Bearer " + API_KEY
    },
    body: formData
})
.then(response => {
    if (!response.ok) {
        throw new Error("HTTP error " + response.status);
    }
    return response.json()
})
.then(json => {
    // 转写的文本在 json.text
})
.catch(error => {
    console.error(error);
});

Alternative

No response

Additional context

OpenAI's audio API charges $0.006 per minute for transcription.

Validations

OMG !! this would be great!!

@ddiu8081
Copy link
Member

Sounds a bit complicated to achieve, but a good feature to use audio api. In v2 I plan to provide a separate panel for the Whisper API, and may not be used in the input box.

@Chanzhaoyu
Copy link

using voice in web pages is restricted by https

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants