Skip to content

Commit 525c18a

Browse files
committed
openai sample
1 parent defb23a commit 525c18a

File tree

1 file changed

+5
-4
lines changed
  • articles/cognitive-services/Speech-Service/includes/quickstarts/openai-speech

1 file changed

+5
-4
lines changed

articles/cognitive-services/Speech-Service/includes/quickstarts/openai-speech/python.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Follow these steps to create a new console application.
8080
def ask_openai(prompt):
8181
8282
# Ask Azure OpenAI
83-
response = openai.Completion.create(engine=deployment_id, prompt=prompt, max_tokens=50)
83+
response = openai.Completion.create(engine=deployment_id, prompt=prompt, max_tokens=100)
8484
text = response['choices'][0]['text'].replace('\n', '').replace(' .', '.').strip()
8585
print('Azure OpenAI response:' + text)
8686
@@ -130,6 +130,7 @@ Follow these steps to create a new console application.
130130
except Exception as err:
131131
print("Encountered exception. {}".format(err))
132132
```
133+
1. To increase or decrease the number of tokens returned by Azure OpenAI, change the `max_tokens` parameter. For more information tokens and cost implications, see [Azure OpenAI tokens](/azure/cognitive-services/openai/overview#tokens) and [Azure OpenAI pricing](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/).
133134

134135
Run your new console application to start speech recognition from a microphone:
135136

@@ -149,9 +150,9 @@ Recognized speech:Make a comma separated list of all continents.
149150
Azure OpenAI response:Africa, Antarctica, Asia, Australia, Europe, North America, South America
150151
Speech synthesized to speaker for text [Africa, Antarctica, Asia, Australia, Europe, North America, South America]
151152
Azure OpenAI is listening. Say 'Stop' or press Ctrl-Z to end the conversation.
152-
Recognized speech:Make a comma separated list of 1 Astronomical observatory for each continent. The list should include each continent name in parentheses.
153-
Azure OpenAI response:Mauna Kea Observatory (North America), European Southern Observatory (Europe), Atacama Large Millimeter Array (South America), Siding Spring Observatory (Australia), and South African Astronomical Observatory (Africa)
154-
Speech synthesized to speaker for text [Mauna Kea Observatory (North America), European Southern Observatory (Europe), Atacama Large Millimeter Array (South America), Siding Spring Observatory (Australia), and South African Astronomical Observatory (Africa)]
153+
Recognized speech: Make a comma separated list of 1 Astronomical observatory for each continent. A list should include each continent name in parentheses.
154+
Azure OpenAI response:Mauna Kea Observatories (North America), La Silla Observatory (South America), Tenerife Observatory (Europe), Siding Spring Observatory (Australia), Beijing Xinglong Observatory (Asia), Naukluft Plateau Observatory (Africa), Rutherford Appleton Laboratory (Antarctica)
155+
Speech synthesized to speaker for text [Mauna Kea Observatories (North America), La Silla Observatory (South America), Tenerife Observatory (Europe), Siding Spring Observatory (Australia), Beijing Xinglong Observatory (Asia), Naukluft Plateau Observatory (Africa), Rutherford Appleton Laboratory (Antarctica)]
155156
Azure OpenAI is listening. Say 'Stop' or press Ctrl-Z to end the conversation.
156157
Conversation ended.
157158
PS C:\dev\openai\python>

0 commit comments

Comments
 (0)