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

Continuous mode not working #148

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9fde685
Update README.md for Transcribe
vivekuppal Jun 29, 2023
1483fea
Merge pull request #1 from vivekuppal/vu-readme-updates
vivekuppal Jun 29, 2023
391d728
Allow usage without a valid OPEN API key. (#2)
vivekuppal Jun 29, 2023
ab4245d
Update README.md (#3)
vivekuppal Jun 29, 2023
ebb6f2f
Allow user to choose model. Add arguments to main file.
vivekuppal Jun 29, 2023
8f5a595
Code clean up, add linting. (#4)
vivekuppal Jun 30, 2023
59d5c91
UI Text Chronology (#5)
vivekuppal Jun 30, 2023
f772bb8
Update readme with Enhancements. Allow copy of text from UI window. R…
vivekuppal Jun 30, 2023
87a38b1
Save conversation to text. (#9)
vivekuppal Jun 30, 2023
65d6dcf
Add Contextual Information to Responses (#11)
vivekuppal Jun 30, 2023
d1b3c45
Allow users to pause audio transcription. Change the default for gett…
vivekuppal Jul 3, 2023
cfca51a
Update main.py (#15)
abhinavuppal1 Jul 11, 2023
152bad3
Code reorg to separate UI code (#16)
vivekuppal Jul 12, 2023
addf17f
Add support for multiple languages (#18)
vivekuppal Jul 12, 2023
e5cda88
Easy install for non developers on windows (#20)
vivekuppal Jul 18, 2023
9896c1c
Disabled winrar UI (#22)
Adarsha-gg Jul 18, 2023
901501b
When using API, we do not need to specify language, absorb the lang p…
vivekuppal Jul 18, 2023
bd48b61
Language combo fix (#26)
Adarsha-gg Jul 19, 2023
7c9ca88
Added gdrive (#27)
Adarsha-gg Jul 19, 2023
2429c97
Allow usage of API Key in installed version of Transcribe (#28)
vivekuppal Jul 19, 2023
12ef846
updated the drive link (#30)
Adarsha-gg Jul 20, 2023
4be26c7
Add a duration class to easily measure the time taken for an operatio…
vivekuppal Jul 21, 2023
6e53b31
--api option was not working correctly (#34)
vivekuppal Jul 21, 2023
bd42b8c
Initial unit tests for the speech recognition library (#36)
vivekuppal Jul 24, 2023
af87eff
user reported defect fixes. (#39)
vivekuppal Jul 26, 2023
26cfaad
Optimize LLM usage (#40)
vivekuppal Jul 26, 2023
f8d5857
Bug fixes for exceptions observed during usage. Add further plumbing …
vivekuppal Jul 27, 2023
1356a78
Add logging infrastructure (#42)
vivekuppal Jul 27, 2023
a1cc48b
Get Response from LLM on demand (#44)
vivekuppal Jul 28, 2023
ea5f392
Models from open ai site (#43)
Adarsha-gg Jul 28, 2023
b4e03a4
List all active devices (#45)
vivekuppal Aug 1, 2023
85d09ed
Allow user to select input, output audio devices (#48)
vivekuppal Aug 21, 2023
28d1e9a
Disable mic speaker selectively (#49)
vivekuppal Aug 23, 2023
e48bdb8
Add Audio Response for LLM generated content (#50)
vivekuppal Aug 27, 2023
6baa77f
Update, upload latest binaries (#54)
Adarsha-gg Aug 30, 2023
fa55416
Multiturn prompts, bug fixes (#55)
vivekuppal Sep 5, 2023
ce5a1e1
Allow enable/disable speaker and microphone from UI (#56)
Adarsha-gg Sep 6, 2023
e445856
Update gdrive link (#58)
Adarsha-gg Sep 7, 2023
b50f58c
Bring readme up to date with current functionality. Describe content …
vivekuppal Sep 8, 2023
a7ea2cc
Continuous mode broke after updates to the UI.
vivekuppal Sep 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add Contextual Information to Responses (#11)
* Save conversation to text.

* Allow users to customize the prompts and get contextual responses.

* Update readme with feature request for Contextual information.

* Update button text.
  • Loading branch information
vivekuppal committed Jun 30, 2023
commit 65d6dcfbaf58a83ba9833cdcccab394ed8e2c224
3 changes: 3 additions & 0 deletions AudioRecorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
ENERGY_THRESHOLD = 1000
DYNAMIC_ENERGY_THRESHOLD = False


class BaseRecorder:
def __init__(self, source, source_name):
self.recorder = sr.Recognizer()
Expand All @@ -31,11 +32,13 @@ def record_callback(_, audio:sr.AudioData) -> None:

self.recorder.listen_in_background(self.source, record_callback, phrase_time_limit=RECORD_TIMEOUT)


class DefaultMicRecorder(BaseRecorder):
def __init__(self):
super().__init__(source=sr.Microphone(sample_rate=16000), source_name="You")
self.adjust_for_noise("Default Mic", "Please make some noise from the Default Mic...")


class DefaultSpeakerRecorder(BaseRecorder):
def __init__(self):
with pyaudio.PyAudio() as p:
Expand Down
19 changes: 19 additions & 0 deletions CustomPrompts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# A user can customize responses based on contextual information.
# E.g. A biologist might want to provide answers specific to certain study papers.
# An advanced programmer might want to provide answers specific to programming in Rust
#
# It requires some knowledge of Prompt Engineering to craft good preamble, epilogues

DEFAULT_PREAMBLE = """You are a casual pal, genuinely interested in the conversation at hand.""" \
"""A poor transcription of conversation is given below."""

DEFAULT_EPILOGUE = """Please respond, in detail, to the conversation. Confidently give a """\
"""straightforward response to the speaker, even if you don't understand """\
"""them. Give your response in square brackets. DO NOT ask to repeat, """\
"""and DO NOT ask for clarification. Just answer the speaker directly."""

# To provide custom preamble, epilogue, define new constants and assign them to PREAMBLE, EPILOGUE
# Both preamble and epilogue are required

PREAMBLE = DEFAULT_PREAMBLE
EPILOGUE = DEFAULT_EPILOGUE
4 changes: 3 additions & 1 deletion GPTResponder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
# Number of phrases to use for generating a response
MAX_PHRASES = 10


def generate_response_from_transcript(transcript):
try:
prompt_content = create_prompt(transcript)
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo-0301",
messages=[{"role": "system", "content": create_prompt(transcript)}],
messages=[{"role": "system", "content": prompt_content}],
temperature=0.0
)
except Exception as exception:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file

## ➕ Enhancements from base repository ➕
- Do not need Open AI key, paid Open AI account to use the complete functionality
- Allow contexttual information to provide customized responses to users
- Transcribe any video
- Preserve all conversation text in UI
- Allow saving conversation to file
Expand Down
2 changes: 1 addition & 1 deletion custom_speech_recognition/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from .audio import AudioData, get_flac_converter
from .exceptions import (
RequestError,
TranscriptionFailed,
TranscriptionFailed,
TranscriptionNotReady,
UnknownValueError,
WaitTimeoutError,
Expand Down
5 changes: 2 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def create_ui_components(root):
update_interval_slider.set(2)
update_interval_slider.grid(row=3, column=1, padx=10, pady=10, sticky="nsew")

copy_button = ctk.CTkButton(root, text="Copy", command=None)
copy_button = ctk.CTkButton(root, text="Copy Audio Transcript", command=None)
copy_button.grid(row=2, column=0, padx=10, pady=3, sticky="nsew")

save_file_button = ctk.CTkButton(root, text="Save to File", command=None)
Expand All @@ -106,8 +106,7 @@ def main():
'\nbase model has to be downloaded from the link https://drive.google.com/file/d/1E44DVjpfZX8tSrSagaDJXU91caZOkwa6/view?usp=drive_link'
'\nsmall model has to be downloaded from the link https://drive.google.com/file/d/1E44DVjpfZX8tSrSagaDJXU91caZOkwa6/view?usp=drive_link'
'\nOpenAI has more models besides the ones specified above.'
'\nThose models are prohibitive to use on local machines because of memory requirements.'
'\nThis option is only applicable when not using the --api option.')
'\nThose models are prohibitive to use on local machines because of memory requirements.')
args = cmd_args.parse_args()

try:
Expand Down
16 changes: 7 additions & 9 deletions prompts.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
INITIAL_RESPONSE = "Welcome to Transcribe 🤝 👋"
from CustomPrompts import PREAMBLE, EPILOGUE

INITIAL_RESPONSE = '👋 Welcome to Transcribe 🤝'

def create_prompt(transcript):
return f"""You are a casual pal, genuinely interested in the conversation at hand. \
A poor transcription of conversation is given below.

{transcript}.

Please respond, in detail, to the conversation. Confidently give a straightforward response to the speaker,
even if you don't understand them. Give your response in square brackets. DO NOT ask to repeat, and DO NOT ask for
clarification. Just answer the speaker directly."""
def create_prompt(transcript):
return f'{PREAMBLE} \
\
{transcript}.\
{EPILOGUE}'