Spaces:
No application file
No application file
gent commited on
Commit ·
eb02aca
1
Parent(s): a455643
rm proxy
Browse files- app.py +2 -2
- utils/asr.py +2 -2
- utils/tts.py +1 -3
app.py
CHANGED
|
@@ -5,9 +5,9 @@ import os
|
|
| 5 |
|
| 6 |
grammar_prompt="""
|
| 7 |
I want you to act as a grammar mistake checker and make the sentence more fluent. You take all the user input and auto correct it. Just reply to user input with correct grammar and reasons, DO NOT reply the context of the question of the user input. If the user input is grammatically correct and fluent, just ignore it. Sample of the conversation will show below:
|
| 8 |
-
|
| 9 |
Correct: today is a good day.
|
| 10 |
-
|
| 11 |
Original: today is a good day.
|
| 12 |
Corrected: Today is a good day.
|
| 13 |
Reason: Capitalize the first letter of the sentence.
|
|
|
|
| 5 |
|
| 6 |
grammar_prompt="""
|
| 7 |
I want you to act as a grammar mistake checker and make the sentence more fluent. You take all the user input and auto correct it. Just reply to user input with correct grammar and reasons, DO NOT reply the context of the question of the user input. If the user input is grammatically correct and fluent, just ignore it. Sample of the conversation will show below:
|
| 8 |
+
#User
|
| 9 |
Correct: today is a good day.
|
| 10 |
+
#Assistant
|
| 11 |
Original: today is a good day.
|
| 12 |
Corrected: Today is a good day.
|
| 13 |
Reason: Capitalize the first letter of the sentence.
|
utils/asr.py
CHANGED
|
@@ -11,9 +11,9 @@ def get_recoginizer(**kwargs):
|
|
| 11 |
|
| 12 |
def recognize_from_file(file=None):
|
| 13 |
# This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"
|
| 14 |
-
speech_config = speechsdk.SpeechConfig(subscription=os.environ.get('SPEECH_KEY'), region=os.environ.get('SPEECH_REGION'))
|
| 15 |
speech_config.speech_recognition_language="en-US"
|
| 16 |
-
|
| 17 |
audio_config = speechsdk.audio.AudioConfig(filename=file)
|
| 18 |
|
| 19 |
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)
|
|
|
|
| 11 |
|
| 12 |
def recognize_from_file(file=None):
|
| 13 |
# This example requires environment variables named "SPEECH_KEY" and "SPEECH_REGION"
|
| 14 |
+
speech_config = speechsdk.SpeechConfig(subscription=os.environ.get('SPEECH_KEY',''), region=os.environ.get('SPEECH_REGION',''))
|
| 15 |
speech_config.speech_recognition_language="en-US"
|
| 16 |
+
|
| 17 |
audio_config = speechsdk.audio.AudioConfig(filename=file)
|
| 18 |
|
| 19 |
speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_config)
|
utils/tts.py
CHANGED
|
@@ -2,15 +2,13 @@ import azure.cognitiveservices.speech as speechsdk
|
|
| 2 |
import os
|
| 3 |
|
| 4 |
# Create a speech synthesizer object
|
| 5 |
-
speech_config = speechsdk.SpeechConfig(subscription=os.environ.get('SPEECH_KEY'), region=os.environ.get('SPEECH_REGION'))
|
| 6 |
speech_config.speech_synthesis_voice_name = "en-GB-ElliotNeural"; # Set the desired voice here
|
| 7 |
-
speech_config.set_proxy("127.0.0.1", 2080)
|
| 8 |
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config)
|
| 9 |
|
| 10 |
def tts(text)-> speechsdk.SpeechSynthesisResult:
|
| 11 |
# Synthesize the text to audio
|
| 12 |
speech_synthesis_result = speech_synthesizer.speak_text(text)
|
| 13 |
-
|
| 14 |
if speech_synthesis_result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
|
| 15 |
print("Speech synthesized for text [{}]".format(text))
|
| 16 |
elif speech_synthesis_result.reason == speechsdk.ResultReason.Canceled:
|
|
|
|
| 2 |
import os
|
| 3 |
|
| 4 |
# Create a speech synthesizer object
|
| 5 |
+
speech_config = speechsdk.SpeechConfig(subscription=os.environ.get('SPEECH_KEY',''), region=os.environ.get('SPEECH_REGION',''))
|
| 6 |
speech_config.speech_synthesis_voice_name = "en-GB-ElliotNeural"; # Set the desired voice here
|
|
|
|
| 7 |
speech_synthesizer = speechsdk.SpeechSynthesizer(speech_config=speech_config)
|
| 8 |
|
| 9 |
def tts(text)-> speechsdk.SpeechSynthesisResult:
|
| 10 |
# Synthesize the text to audio
|
| 11 |
speech_synthesis_result = speech_synthesizer.speak_text(text)
|
|
|
|
| 12 |
if speech_synthesis_result.reason == speechsdk.ResultReason.SynthesizingAudioCompleted:
|
| 13 |
print("Speech synthesized for text [{}]".format(text))
|
| 14 |
elif speech_synthesis_result.reason == speechsdk.ResultReason.Canceled:
|