Giter VIP home page Giter VIP logo

dotnet-docs-samples's Introduction

Google Cloud Platform .NET Docs Samples

A collection of samples that demonstrate how to call some Google Cloud services from C#.

The APIs and .NET Libraries page lists all the Cloud APIs you can call from .NET.

The samples in this repo cover only some of the total APIs that you can call from .NET.

Google Cloud Samples

You can also browse these samples, and more in Google Cloud Samples.

Build and Run

To build and run a sample, open the solution file (.sln) with Visual Studio 2017 or later and build it.

But no sample will work until you

  1. Follow the set-up instructions in the documentation.

  2. Download or clone this repo with

    git clone https://github.com/GoogleCloudPlatform/dotnet-docs-samples

    Browse the directories, find a solution (.sln) file, open it with Visual Studio 2017 or later, and run it!

Contributing changes

Licensing

Testing

dotnet-docs-samples's People

Contributors

alixhami avatar amanda-tarafa avatar anshuldavid13 avatar avaksman avatar averikitsch avatar billyjacobson avatar deren-liao avatar dpebot avatar frankyn avatar hemanshv avatar irataxy avatar jahjahbin avatar jainamtrivedi-crest avatar jesselovelace avatar jsimonweb avatar jskeet avatar laljikanjareeya avatar melaniedejong avatar meredithslota avatar meteatamel avatar mkoshurnikov avatar munkhuushmgl avatar peter-zheng-g avatar pheonixblade9 avatar renovate-bot avatar ryanmats avatar sethvargo avatar skuruppu avatar surferjeffatgoogle avatar telpirion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dotnet-docs-samples's Issues

On textDetection sample don't work on Thai Language

Hi Google cloud team,

On textDetection sample don't work on Thai Language.
Can't translate on the message.

Question:

  1. It's support only english language ?
  2. How we can modify the source code for support other language ?

Thanks you

NAudio has conflict with speech api samples

Steps to Reproduce

  1. Clone the repo and download
  2. Find the speech sln and load it
  3. When VS rebuilds the solution, you should the following error:

Package 'NAudio 1.8.4' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.

NAudio and .NET 2.0 seems to be the issue

Please see this issue on NAudio as follows. Please see here.

google api speech recognition not working after 60 seconds

I am testing google api streamimg speech recognition.
I opened this project https://github.com/GoogleCloudPlatform/dotnet-docs-samples/tree/master/speech/api/Recognize
and ran StreamingMicRecognizeAsync method from main. It was working fine.
But after 60 seconds or so it stopped recognizing audio from mic. I tried increasing the time in "ListenOptions.Seconds". It did not help.

did anyone face the same issue and find some workaround ?

Thanks.

All BigQuery samples should poll to wait for completion

There isn't really a difference between "sync/asynch" queries. I'm working to remove this distinction from the docs.

Please update all query samples to look more like this one, where they poll for results:

Even if the "synchronous" request times out, the job is still running. Most people will want to wait for the results.

Storage test doesn't actually run any tests.

From the test log:
Test Settings: Default Test Settings
storage\api\test\test.csproj
Microsoft (R) Test Execution Command Line Tool Version 14.0.23107.0
Copyright (c) Microsoft Corporation. All rights reserved.

Loading bin\debug\test.dll...
Starting execution...
No tests to execute.

Pub/Sub tests need to handle eventual consistency

There has been a long streak of failed pubsub tests. We need to make them handle eventual consistency. For example, this code:

            CreateTopicMessage(topicId, _publisher);
            //Pull the Message to confirm it is valid
            PullResponse response = PullTopicMessage(subscriptionId, _subscriber);
            Assert.False(IsEmptyResponse(response));

There is no guarantee that the message will be immediately available in the subscription. We need Eventually() wrappers around this and similar code.

Lag time in response

I'm using Node implementation of Google Speech to Text API, but the lag time is too much --- 3-4 seconds in response time. Is this normal? Is there a way to get it to less than 2 seconds?

Samples for flexible app engine and IISIntegration

It appears all of the samples provided for the flexible App Engine environment were created using "dotnet new" and as a result include a web.config and .UseIISIntegration() for Kestrel in the Program.cs.

From what I can tell based on the docker images the App Engine sets the PORT environmental variable in the container which is then exposed via docker and then Kestrel is set to use this port using the ASPNETCORE_URLS environmental variable via ASPNETCORE_URLS=http://*:${PORT}.

If this is the case and the web.config and IIS integration are not needed, I suggest removing them as being in the samples may suggest some IIS dependency.

Text to speech sample

Hi,
do you plan to create sample project for .net showing text to speech api usage?
I checked it, but I didn't understand how to use it.

Petr

AppEngine flex samples run locally on windows

The samples for netcore on app engine flex all show running the apps in visual studio on a local windows machine. When the apps are deployed they are run on a debian8 linux container.

Although it is improving, the current state of cross platform support in netcore is not 100%. I've run into many issues moving code from windows to linux and had to implement workarounds. It would be helpful to show a sample of doing local development on a windows pc using the same linux containers that the app will be deployed under in the flex app engine.

This is relatively easy now with Docker for Windows and Docker tools for VS. If desired I can update a repo and submit a pull request.

Using .flac format Syncrecognize gives null as results and Etag

I am using .flac format file for google speech api SyncRecognize method but it always returns results and Etag as null. I am using Naudio to record my .wav file and i am converting it to .flac ,and after sending this .flac file to syncRecognize it gives null result always.Its Urgent.
Please Help to resolve this.

speech.Recognize() doesn't return, throws exception after 10 minutes saying "DeadlineExceeded"

I am using this slightly modified version of the code from this repository:

public async Task<string> TranscribeSpeech(string filenameAndPath, int WAVSampleRate = 8000)
    {
        Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", Utils.GetHomeFolder() + @"\Google Speech API Key.json"); //for authentication

        var language = WebConfigurationManager.AppSettings["GoogleSpeechFromLocale"];

        var speech = SpeechClient.Create();
        var response = await speech.RecognizeAsync(new RecognitionConfig()
        {
            Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
            SampleRateHertz = WAVSampleRate,
            LanguageCode = language,
        }, RecognitionAudio.FromFile(filenameAndPath));

        return response.Results.First().Alternatives.First().Transcript;
    }

The .Recognize() or .RecognizeAsync() methods never return anything and throw an exception after 10 minutes saying Status(StatusCode=DeadlineExceeded,Detail="Deadline Exceeded")!.

Is there an issue with the code or with the API settings?

proxy configuration

How can we set proxy in speech sdk.we need to use proxy while consuming speech to text services and I have noticed that even setting proxy in web.config, sdk ignores it and hits google API directly ignoring proxy configuration.can u pls guide us on proxy configuration

RecognitionConfig.SpeechContext is have not been provided yet?

Hi.
I use Speech API.
I want to use RecognitionConfig.SpeechContext, but is required set SpeechContext type.
I search sample, but no sample found.
Now, SpeechContext.Phrases is gettable, but no settable.
is this have not been provided yet?
If not, please tell me a usage example.

Credential Error: Error deserializing JSON credential data

Hi,
I'm using the vision api (via ImageAnnotatorClient) and upon instantiating I get the following error:
"Error reading credential file from location [PATH]: Error deserializing JSON credential data.\nPlease check the value of the Environment Variable GOOGLE_APPLICATION_CREDENTIALS"
Problem is, I cloned the vision api sample in this repo and that runs just fine so I know that the environment variable is set correctly and that the info inside my credential file is in the right format. Both where I want to use this in my own code (not working) and in the test code (working) have the same code:

// Instantiates a client
var client = ImageAnnotatorClient.Create();
// Load the image file into memory
Image image = Image.FetchFromUri(url);
//Performs label detection on the image file
var response = client.DetectLabels(image);

and have the same version of Newtonsoft.Json (10.0.2) and target the same framework (.net 4.5). My failure is coming from the first line.

Note: Maybe its worth mentioning that the error producing code is contained within a Class Library project that is used by a Console Application project and the working code is directly in the Console Application.

SpeechContext appears to be read-only

Using the RecognitionConfig object for speech recognition, we have not found a way to set the properties in a SpeechContext object in C#. The Intellisense blocks us from setting any Phrases (or any other object) by only offering Read-Only properties (GETs). We have seen no way to write to these properties (SETs).

Here is the example from one of our attempts:
1

In this attempt, we were going to assign test to the SpeechContext as shown below:
2

Thank you!

AuthTest test fails

But only when running automated tests. I suspect that this is happening because two tests are running simultaneously. But two applications should be able to run simultaneously.

I will turn off running tests in parallel to see if it fixes it. If it fixes it, then it's a bug in the libs.

Test method AuthTest.Test.TestListBucketContents threw exception: 
System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: Error reading credential file from location C:\users\root\Documents\silver-python2-b6dac6d6b9a8.json: The process cannot access the file 'C:\users\root\Documents\silver-python2-b6dac6d6b9a8.json' because it is being used by another process.
Please check the value of the Environment Variable GOOGLE_APPLICATION_CREDENTIALS

Google.Apis.Auth.OAuth2.DefaultCredentialProvider.<CreateDefaultCredentialAsync>d__0.MoveNext() in c:\ApiaryDotnet\default\Src\GoogleApis.Auth.DotNet4\OAuth2\DefaultCredentialProvider.cs: line 95
System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
System.Threading.Tasks.Task`1.get_Result()
GoogleCloudSamples.AuthSample.CreateAuthorizedClient() in C:\users\root\workspace\dotnet-docs-samples\auth\Program.cs: line 38
AuthTest.Test.TestListBucketContents() in C:\users\root\workspace\dotnet-docs-samples\auth\test\Test.cs: line 46

Using custom credentials with Speech API

When I use Speech API in a hosted environment (Azure), I don't know the path to the credentials file in advance. I know that we can create a GoogleCredential instance from a file. But how do I use it when I create a SpeechClient instance? Would be great if you could provide a code example for this.

Google Speech To Text by Microfone

I am working on Google Speech by c # . I want to use the microphone . My code is there But My code uses only audio files. Please help me . Thank you

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Google.Cloud.Speech.V1Beta1;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
var speech = SpeechClient.Create();
var response = speech.SyncRecognize(new RecognitionConfig()
{
LanguageCode = "tr-TR",
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
SampleRate = 16000,
}, RecognitionAudio.FromFile("audio.wav"));
foreach (var result in response.Results)
{
foreach (var alternative in result.Alternatives)
{
Console.WriteLine(alternative.Transcript);
} }
Console.ReadLine();
}}}

Return status of LongOperation

Hi Guys,

This is not an issue but more of a request for help. Does anyone know how I can return the progress or status of the long running operation. Below is my current code but have no clue how to return the progress as I couldn't find it in the documentation. I am using Google.Cloud.Speech.V1.
`dynamic audiofile = "gs://mybucket/test2.wav";

dynamic speech = SpeechClient.Create();
dynamic longOperation = await speech.LongRunningRecognizeAsync(new RecognitionConfig {
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
SampleRateHertz = 8000,
LanguageCode = LanguageCodes.English.UnitedKingdom
}, RecognitionAudio.FromStorageUri(audiofile));
longOperation = await longOperation.PollUntilCompletedAsync();

dynamic response = longOperation.Result;

foreach (object result in response.Results) {

foreach (object alternative in result.Alternatives) {
	txtReturn.Text = txtReturn.Text + alternative.Transcript;
	MyObservable.Add(new TranscriptionResult {
		Transcript = alternative.Transcript,
		Confidence = alternative.Confidence
	});

}

}`

I appreciate your assistance with this.

Issue: audio data is being streamed too slow. please stream audio data approximately at real time

I'm using below method to convert speech to text using microphone, and the sample rate is 16000. I have tested it on Windows 10 machine initially and it worked fine and later when I tested the same script on Windows 7 machine it is not working properly and I'm getting the below error message.

audio data is being streamed too slow. please stream audio data approximately at real time

How to decide which sample rate to beused on which machine? What could be the problem with my Windows 7 machine?

// [START speech_streaming_mic_recognize]
static async Task StreamingMicRecognizeAsync(int seconds)
{
// code here....
StreamingConfig = new StreamingRecognitionConfig()
{
Config = new RecognitionConfig()
{
Encoding =
RecognitionConfig.Types.AudioEncoding.Linear16,
SampleRate = 16000,
},
InterimResults = false,
}
// code here........
}

Please help me in fixing this issue.

Json string to AnnotateTextResponse object

Hello,

Any one has solution to convert Json string to AnnotateTextResponse object? see below code for more details

private static void AnalyzeSyntax(string text, string encoding = "UTF16")
        {
            var client = LanguageServiceClient.Create();
            var response = client.AnnotateText(new Document()
            {
                Content = text,
                Type = Document.Types.Type.PlainText
            },
            new Features() { ExtractSyntax = true });
            string jsonString = response.ToString();

            // HERE I HAVE ADDED CODE TO DO REVERSE PROCESS (JSON STRING TO ANOTATETEXTRESPONSE)
            var stringFromDatabase = jsonString;
            AnnotateTextResponse anotateTextResponseObj = ??????(jsonString); // I need some code here that can convert Json string to AnnotateTextResponse object

}

Thanks,
Ashish

Got exection 'System.InvalidOperationException' occurred in Google.Api.Gax.dll

hi, I followed each and every steps given in both readme docs. I set GOOGLE_APPLICATION_CREDENTIALS in to the environment variable of windows from System Properties\Advance system settings with path of it's json file location in my computer. I got the credential from console.cloud.google.com according to structured format. And finally, I built the project before start running. But once I run the project and set startup project as QuickStart Project, I got an Exeption at var speech = SpeechClient.Create(); in QuickStart.cs file. What I am doing wrong, I don't get it till now. Here is the details of exception:

"An unhandled exception of type 'System.InvalidOperationException' occurred in Google.Api.Gax.dll

Additional information: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information."

StackTrace: at Google.Api.Gax.TaskExtensions.WaitWithUnwrappedExceptions(Task task)
at Google.Api.Gax.TaskExtensions.ResultWithUnwrappedExceptions[T](Task`1 task)
at Google.Api.Gax.Grpc.ChannelPool.GetChannel(ServiceEndpoint endpoint)
at Google.Cloud.Speech.V1Beta1.SpeechClient.Create(ServiceEndpoint endpoint, SpeechSettings settings)
at GoogleCloudSamples.QuickStart.Main(String[] args) in D:\Drive-F\Study\Google Cloud Speech Recognition\dotnet-docs-samples-master\dotnet-docs-samples-master\speech\api\QuickStart\QuickStart.cs:line 30
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.