اذهب الي المحتوي
أوفيسنا

هل فى امكانيه فى الاكسيس تحويل الصوت لكتابه زى جوجل


safaa salem5

الردود الموصى بها

على ما أذكر ، نعم هذا ممكن ، ولكنها غير مجانية من Google .

 

إذا كان مقدم الخدمة Google ، وترغبي في استخدام Google Cloud Speech-to-Text ، يجب أن تتبع الخطوات التالية:

أولاً الحصول على مفتاح API:

انتقل إلى Google Cloud Console وقومي بإنشاء مشروع جديد ( كتجربة مجانية طبعاً ).
انتقل إلى "APIs & Services" > "Dashboard" وقومي بتفعيل خدمة Cloud Speech-to-Text API لمشروعك.
وستحصلي على مفتاح API من قسم "Credentials".


الآن إعداد Google Cloud Speech-to-Text في VBA:

قومي بتحميل وتثبيت مكتبة HTTPRequests ، في VBA إذا لم تكن مثبتة بالفعل.
استخدم الكود التالي كمثال للاتصال بخدمة Google Cloud Speech-to-Text

Function ConvertSpeechToText(audioFilePath As String) As String
    Dim apiUrl As String
    Dim apiKey As String
    Dim audioData As String
    Dim http As Object
    
    ' تعيين قيم apiUrl وapiKey وaudioData باستخدام مفتاح API الخاص بك
    apiUrl = "https://speech.googleapis.com/v1/speech:recognize?key=YOUR_API_KEY"
    apiKey = "your_api_key"
    
    ' قراءة بيانات الصوت من ملف
    ' يمكنك ضبط هذا بناءً على كيفية تخزين الصوت في مشروعك
    ' على سبيل المثال، يمكنك استخدام دالة FileToString لقراءة الصوت من ملف
    ' audioData = FileToString(audioFilePath)

    ' إرسال الطلب إلى Google Cloud Speech-to-Text API
    Set http = CreateObject("MSXML2.ServerXMLHTTP")
    
    http.Open "POST", apiUrl, False
    http.setRequestHeader "Content-Type", "application/json"
    
    ' تكوين جسم الطلب
    Dim jsonBody As String
    jsonBody = "{""config"": {""encoding"": ""LINEAR16"",""sampleRateHertz"": 16000,""languageCode"": ""en-US""},""audio"": {""content"": """ & audioData & """}}"
    
    http.send jsonBody

    ' معالجة الاستجابة
    If http.Status = 200 Then
        ' تحديث حقل النص في قاعدة البيانات
        ConvertSpeechToText = http.responseText
    Else
        ' معالجة الأخطاء هنا
        ConvertSpeechToText = "Error: " & http.Status & " - " & http.statusText
    End If
End Function

لم تتم التجربة طبعاً :biggrin:

ولكن كفكرة أعتقد أنها ممكنة ، وبانتظار الأساتذة مشاركتنا خبرتهم

 

رابط هذا التعليق
شارك

1 ساعه مضت, safaa salem5 said:

الصوت لكتابه زى جوجل

الصوت ل كتابة
واللا الكتابة لصوت ؟

وايه نوع الكتابة يعنى كلمات ثابته
زاللا متغيرة
ياريت توضيح اكثر لوضع افضل تصور طبقا لذلك التوضيح :yes:

رابط هذا التعليق
شارك

14 minutes ago, ابو جودي said:

الصوت ل كتابة
واللا الكتابة لصوت ؟

وايه نوع الكتابة يعنى كلمات ثابته
زاللا متغيرة
ياريت توضيح اكثر لوضع افضل تصور طبقا لذلك التوضيح :yes:

عندى فورم فيه مربعات نص كتير

عايزه بدل ما اكتب

اتكلم

 ويتم التنقل بين مربعات النص بمجرد انتهاء الفويس تلقائي 

طبعا الكلام متغير

هل دا ممكن

 

 

 

 

تم تعديل بواسطه safaa salem5
رابط هذا التعليق
شارك

طيب

الكود 
طبعا لم ولن استطيع التجربة ولكن وجدت هذا الشرح ودى الترجمة اللى انا فهمتها

لفعل ذلك، يمكنك استخدام خدمة تحويل الصوت إلى نص مثل Azure Speech Services أو Google Cloud Speech-to-Text.
يجب أن يكون لديك مفاتيح API الخاصة بك من Google Cloud لتنفيذ هذا الكود.

  1. تحتاج إلى إضافة مربع نص (TextBox) في نموذج Access للعرض النص المحول من الصوت.

  2. قم بإضافة المرفق النموذجي لـ Microsoft XML (MSXML) إلى المراجع (References) في VBA.

  3. استخدم الكود التالي في VBA:

 

Sub ConvertSpeechToText()
    Dim apiKey As String
    Dim audioFilePath As String
    Dim textBoxName As String
    Dim accessToken As String
    Dim xhr As Object
    Dim responseText As String
    
    ' Set your Google Cloud API key
    apiKey = "Your_Google_Cloud_API_Key"
    
    ' Set the path to the audio file (recorded audio file)
    audioFilePath = "C:\Path\To\Your\Audio\File.wav"
    
    ' Name of the text box where you want to display the text
    textBoxName = "txtSpeechToText"
    
    ' Get the access token
    accessToken = GetGoogleCloudAccessToken(apiKey)
    
    ' Create XMLHTTP object
    Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    
    ' Configure the request
    xhr.Open "POST", "https://speech.googleapis.com/v1/speech:recognize?key=" & apiKey, False
    xhr.setRequestHeader "Content-Type", "application/json"
    
    ' Configure the request body
    xhr.send "{""config"": {""encoding"": ""LINEAR16"", ""sampleRateHertz"": 16000, ""languageCode"": ""en-US""}, ""audio"": {""content"": """ & Base64Encode(audioFilePath) & """}}"
    
    ' Read the response
    responseText = xhr.responseText
    
    ' Parse the response and extract the text
    Dim jsonResponse As Object
    Set jsonResponse = JsonConverter.ParseJson(responseText)
    
    Dim recognizedText As String
    recognizedText = jsonResponse("results")(1)("alternatives")(1)("transcript")
    
    ' Display the text in the text box
    Forms("YourFormName").Controls(textBoxName).Value = recognizedText
    
    ' Close objects
    Set xhr = Nothing
    Set jsonResponse = Nothing
End Sub

Function GetGoogleCloudAccessToken(apiKey As String) As String
    Dim xhr As Object
    Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    
    xhr.Open "POST", "https://www.googleapis.com/oauth2/v4/token", False
    xhr.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    
    xhr.send "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Aapikey&key=" & apiKey
    
    Dim jsonResponse As Object
    Set jsonResponse = JsonConverter.ParseJson(xhr.responseText)
    
    GetGoogleCloudAccessToken = jsonResponse("access_token")
    
    Set xhr = Nothing
    Set jsonResponse = Nothing
End Function

Function Base64Encode(filePath As String) As String
    Dim stream As Object
    Set stream = CreateObject("ADODB.Stream")
    
    stream.Type = 1 ' adTypeBinary
    stream.Open
    stream.LoadFromFile filePath
    
    Base64Encode = Convert.ToBase64String(stream.Read)
    
    Set stream = Nothing
End Function

 

رابط هذا التعليق
شارك

من فضلك سجل دخول لتتمكن من التعليق

ستتمكن من اضافه تعليقات بعد التسجيل



سجل دخولك الان
  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information